Skip to content

Instantly share code, notes, and snippets.

@hchbaw
Created April 9, 2010 14:30
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 hchbaw/361216 to your computer and use it in GitHub Desktop.
Save hchbaw/361216 to your computer and use it in GitHub Desktop.
#!zsh
# 直前のコマンドラインの要素を補完候補にするようなスクリプトです。
_complete_previous_commandline () {
local cl xs
cl="$(fc -l -n -1)"
xs=${(@z)cl}
compadd \
-V "previous commandline" \
-M 'm:{a-z}={A-Z} r:|?=**' \
-x "(${(Q)cl})" \
-- $xs
}
zle -C complete-previous-commandline complete-word _complete_previous_commandline
# bindkey "^X^p" complete-previous-commandline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment