zsh: use a ZLE widget to save command line when opening nvim with ctrl-v

This commit is contained in:
Fernando Schauenburg 2024-08-01 23:03:46 +02:00
parent 3ac248c53d
commit e0b35d87d4

View file

@ -194,6 +194,14 @@ fs_setup_zle() {
zle accept-line zle accept-line
} }
# Open nvim, preserving the current command line.
zle -N fs_zle_open_nvim
fs_zle_open_nvim() {
zle push-line
BUFFER="nvim"
zle accept-line
}
autoload edit-command-line && zle -N edit-command-line # from zshcontrib autoload edit-command-line && zle -N edit-command-line # from zshcontrib
############################# #############################
@ -211,7 +219,7 @@ fs_setup_zle() {
# ^r history search using fzf # ^r history search using fzf
# ^t paste file/directory using fzf # ^t paste file/directory using fzf
bindkey -M viins '^u' kill-whole-line bindkey -M viins '^u' kill-whole-line
bindkey -s '^v' '^unvim\r' bindkey -M viins '^v' fs_zle_open_nvim
bindkey -M viins '^x^e' edit-command-line bindkey -M viins '^x^e' edit-command-line
bindkey -M viins '^y' yank bindkey -M viins '^y' yank