Compare commits
No commits in common. "e608cda5935635843b1b88ac24333b2f3cd9cf3e" and "fff303850e984cb28193f9c965db6790b110f02d" have entirely different histories.
e608cda593
...
fff303850e
|
@ -152,28 +152,24 @@ function merge-hist {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sync-history {
|
function sync-history {
|
||||||
local local_history="$HOME/.histfile"
|
|
||||||
local remote_file="sage@sagev.space:~/histfile"
|
|
||||||
local copy_of_remote="$HOME/.tmp/.histfile"
|
|
||||||
local merged="$HOME/.tmp/$(whoami).histfile"
|
|
||||||
|
|
||||||
echo "Downloading shared history..."
|
echo "Downloading shared history..."
|
||||||
if ! tscp -P 11275 "$remote_file" "$copy_of_remote"; then
|
if ! tscp -P 11275 'sage@sagev.space:~/histfile' "$HOME/.tmp/.histfile"; then
|
||||||
echo "Shared history download failed!"
|
echo "Shared history download failed!"
|
||||||
tscp -P 11275 "$local_history" "$remote_file"
|
tscp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo "Merging history files..."
|
echo "Merging history files..."
|
||||||
fc -W # Write to history file
|
fc -W # Write to history file
|
||||||
merge-hist "$local_history" "$copy_of_remote" > "$merged"
|
local merged_name="$HOME/.tmp/$(whoami).histfile"
|
||||||
if ! (($(cat "$merged" | wc -l) > $(cat "$copy_of_remote" | wc -l))); then
|
merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$merged_name"
|
||||||
echo "Merged histfile '$merged' somehow smaller than current histfile"
|
if ! (($(cat "$merged_name" | wc -l) > $(cat "$HOME/.tmp/.histfile" | wc -l))); then
|
||||||
|
echo "Merged histfile '$merged_name' somehow smaller than current histfile"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
mv "$merged" "$local_history"
|
mv "$merged_name" "$HOME/.histfile"
|
||||||
fc -R # Read from new history file
|
fc -R # Read from new history file
|
||||||
echo "Uploading new shared history..."
|
echo "Uploading new shared history..."
|
||||||
tscp -P 11275 "$local_history" "$remote_file"
|
tscp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install-extension {
|
function install-extension {
|
||||||
|
|
Loading…
Reference in New Issue