From 81e83ab9560eaec99305e2cc08f35bd234c89664 Mon Sep 17 00:00:00 2001 From: "xiongdian.me" Date: Wed, 1 Feb 2023 20:01:01 +0800 Subject: [PATCH] fix zsh hist with no new line at the end --- tools/append_zsh_hist.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/append_zsh_hist.sh b/tools/append_zsh_hist.sh index 071295f..ce7d767 100755 --- a/tools/append_zsh_hist.sh +++ b/tools/append_zsh_hist.sh @@ -9,7 +9,9 @@ do_append() { timestamp=$(date +%s) while read -r line; do - echo ": $timestamp:0;$line" >> "$zsh_hist_file" + if [[ -n "$line" ]]; then + echo ": $timestamp:0;$line" >> "$zsh_hist_file" + fi done } @@ -24,7 +26,7 @@ main() if [[ -z "$k" ]]; then continue fi - curl -fsSL "https://pastebin.com/raw/$k" | do_append + (curl -fsSL "https://pastebin.com/raw/$k" && echo) | do_append done }