aboutsummaryrefslogtreecommitdiffstats
path: root/sh
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-03-08 02:40:01 -0500
committerJesse Luehrs <doy@tozt.net>2018-03-08 02:41:06 -0500
commitd50dd19f6f93becacf30419695e21200dc210a34 (patch)
tree40282b7d761f4734afd56e9d9f54538b62fe1be5 /sh
parent1b511a45e7020f7096786d68e939286f9615647b (diff)
downloadvim-history-sync-d50dd19f6f93becacf30419695e21200dc210a34.tar.gz
vim-history-sync-d50dd19f6f93becacf30419695e21200dc210a34.zip
initial implementation
Diffstat (limited to 'sh')
-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
+}