diff --git a/fake_home/.zshrc b/fake_home/.zshrc index e8ad6a6..4191782 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -160,8 +160,13 @@ function sync-history { fi echo "Merging history files..." fc -W # Write to history file - merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile" - mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile" + local merged_name="$HOME/.tmp/$(whoami).histfile" + merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$merged_name" + if ! (($(cat "$merged_name" | wc -l) > $(cat "$HOME/.tmp/.histfile" | wc -l))); then + echo "Merged histfile '$merged_name' somehow smaller than current histfile" + return + fi + mv "$merged_name" "$HOME/.histfile" fc -R # Read from new history file echo "Uploading new shared history..." tscp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'