Skip to content

Instantly share code, notes, and snippets.

@blueyed
Created March 5, 2015 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blueyed/a224f5a874a6af242697 to your computer and use it in GitHub Desktop.
Save blueyed/a224f5a874a6af242697 to your computer and use it in GitHub Desktop.
# Look for $4 (in "word boundaries") in preexec arguments ($1, $2, $3).
_user_execed_command() {
local lookfor="(*[[:space:]])#$4([[:space:]-]*)#"
local ret=1
if [[ $3 == ${~lookfor} ]]; then
_zsh_prompt_preexec_info+=("%{${fg[cyan]}%}⟳")
ret=0
else
local lookfor_quoted="(*[[:space:]=])#(|[\"\'\(])$4([[:space:]-]*)#"
local -a typed
if (( $#_zsh_resolved_jobspec )); then
typed=(${(z)_zsh_resolved_jobspec})
else
typed=(${(z)1})
fi
# Look into resolved aliases etc, allowing the command to be quoted.
# E.g. with `gcm`: noglob _nomatch command_with_files "git commit --amend -m"
local whence_typed="$(whence -f ${typed[1]})"
if [[ ${whence_typed} == ${~lookfor_quoted} ]] ; then
_zsh_prompt_preexec_info+=("%{${fg[cyan]}%}⟳2")
ret=0
elif [[ $commands[$typed[1]]:A:t == ${~lookfor} ]]; then
_zsh_prompt_preexec_info+=("%{${fg[cyan]}%}⟳3")
ret=0
fi
fi
return $ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment