This commit is contained in:
drbo 2014-03-08 17:50:37 +00:00
commit 1834fe2d8e
2 changed files with 42 additions and 17 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ custom/*
*.swp *.swp
!custom/example.zshcache !custom/example.zshcache
cache/ cache/
*~

View file

@ -27,8 +27,32 @@ function omz_termsupport_preexec {
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
local LINE="${2:gs/$/\\$}" local LINE=${2}
LINE="${LINE:gs/%/%%}"
if [[ -o PROMPT_BANG ]]; then
# We must escape ! so that it is not interpreted as a history event number
LINE=${LINE:gs/\!/\!\!}
CMD=${CMD:gs/\!/\!\!}
fi
if [[ -o PROMPT_SUBST ]]; then
# We must escape '\', '$', and '`'
# The backslash is the escape character, and so must be escaped first.
# Both '$' and '`' initiate command substitution, and
# the former initiates arithmetic and parameter expansion
CMD=${CMD:gs/\\/\\\\} # escapses \ -- must be first
CMD=${CMD:gs/$/\\$}
CMD=${CMD:gs/\`/\\\`}
local LINE=${LINE:gs/\\/\\\\} # escapes \ -- must be first
LINE=${LINE:gs/$/\\$}
LINE=${LINE:gs/\`/\\\`}
fi
if [[ -o PROMPT_PERCENT ]]; then
# We must escape % so that it is not interpreted as starting an escape sequence
CMD=${CMD:gs/%/%%}
LINE=${LINE:gs/%/%%}
fi
title "$CMD" "%100>...>$LINE%<<" title "$CMD" "%100>...>$LINE%<<"
} }