From 26d9b87834ff1503f5d06235e3b155ab082e4ae4 Mon Sep 17 00:00:00 2001 From: Vito Botta Date: Tue, 17 Oct 2023 00:25:46 +0300 Subject: [PATCH] Resolve conflicts automatically --- sync-history.sh | 3 ++- zsh.include.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sync-history.sh b/sync-history.sh index 92ef7db..488b17c 100755 --- a/sync-history.sh +++ b/sync-history.sh @@ -29,6 +29,7 @@ last_executed_time=$(cat $last_command_timestamp_file 2>/dev/null || echo 0) if (( current_time - last_executed_time >= 15 )) || [ "$force_sync" = "-f" ]; then { git -C $repo_dir pull > /dev/null 2>&1 + git -C $repo_dir checkout --theirs $sync_file > /dev/null 2>&1 if [[ -f $sync_file ]]; then temp_sync_file=$(mktemp) @@ -40,7 +41,7 @@ if (( current_time - last_executed_time >= 15 )) || [ "$force_sync" = "-f" ]; th fi source_items=$(read_file $source_file) - items=$(echo -e "$source_items\n$new_items" | sort | uniq) + items=$(echo -e "$source_items\n$new_items" | grep -v '^\:\s[<=>]\{3\}' | sort | uniq) echo -e "$items" > $source_file echo -e "$items" | openssl enc -aes-256-cbc -md sha256 -out "$sync_file" -pass file:"$encryption_key_file" -pbkdf2 diff --git a/zsh.include.sh b/zsh.include.sh index a95e9f0..86b51b5 100644 --- a/zsh.include.sh +++ b/zsh.include.sh @@ -1,12 +1,12 @@ fzf-history-widget() { setopt extendedglob - fc -R + fc -R ~/.zsh_history LBUFFER=$(fc -l -n -1 0 | awk '!x[$0]++' | fzf --height=40% --border --prompt="Select command: " --query="$LBUFFER") zle redisplay } __reload_history() { - fc -R + fc -R ~/.zsh_history } __sync_history() {