Created
March 5, 2015 01:03
-
-
Save blueyed/a224f5a874a6af242697 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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