diff options
Diffstat (limited to 'sh/history-sync.zsh')
-rw-r--r-- | sh/history-sync.zsh | 17 |
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 +} |