aboutsummaryrefslogtreecommitdiffstats
path: root/sh/history-sync.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/history-sync.zsh')
-rw-r--r--sh/history-sync.zsh17
1 files changed, 17 insertions, 0 deletions
diff --git a/sh/history-sync.zsh b/sh/history-sync.zsh
new file mode 100644
index 0000000..586417f
--- /dev/null
+++ b/sh/history-sync.zsh
@@ -0,0 +1,17 @@
+mkdir -p $HOME/.cache/vim/hist
+function vim {
+ local zsh_hist_fname
+ zsh_hist_fname=$HOME/.cache/vim/hist/$$
+ command vim --cmd "let g:_zsh_hist_fname = '$zsh_hist_fname'" "$@"
+ if [[ -r $zsh_hist_fname ]]; then
+ while read line; do
+ if echo $line | grep -q "[[:space:]']"; then
+ line=${line/\'/\'\\\\\'\'}
+ line="'$line'"
+ fi
+ print -s "vim $line"
+ done < $zsh_hist_fname
+ fc -AI
+ rm -f $zsh_hist_fname
+ fi
+}