Escape % in $CMD variable
Fixes formatting on some rare cases when a percent ends up
in the $CMD variable, like these below:
- When assigning a variable, $CMD ends up with the second parameter;
in this case, $CMD will contain '+%s%N', messing with the syntax:
$ a=`date +%s%N`
- A function (or command in general) that contains a percent symbol:
$ to\%() { echo $(( $1 * 100 / $3))\% } # $CMD=to%()
$ to% 2 of 10 # $CMD=to%
Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index 5f2fe63d422f6b0df580092fe8c51f0d67ed9fe6..9c0a430fb9bc676fec0810822de552c655687894 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -26,8 +26,11 @@ function omz_termsupport_precmd {
6 function omz_termsupport_preexec {
7 emulate -L zsh
8 setopt extended_glob
9- local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
10+
11+ # cmd name only, or if this is sudo or ssh, the next cmd
12+ local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]:gs/%/%%}
13 local LINE="${2:gs/%/%%}"
14+
15 title '$CMD' '%100>...>$LINE%<<'
16 }
17