Skip to content

Instantly share code, notes, and snippets.

@kalos
Created March 6, 2010 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalos/323699 to your computer and use it in GitHub Desktop.
Save kalos/323699 to your computer and use it in GitHub Desktop.
bindkey "^v" edit_command_line
edit_command_line () {
# edit current line in $EDITOR
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" >$tmpfile
exec </dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
zle kill-buffer
BUFFER=${"$(<$tmpfile)"/$PREBUFFER/}
CURSOR=$#BUFFER
command rm -f $tmpfile
zle redisplay
}
zle -N edit_command_line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment