43bd46b780cdf60b318f452e40b893ae18e77c41

Author
Markus Scherer <markus.f.scherer@gmail.com>
Committer
Markus Scherer <markus.f.scherer@gmail.com>
Date

Message

fix title setting bug in xterm and urxvt

Before this patch, commands containing %-signs set the title wrong
(urxvt and xterm) [1] and produce strange output in urxvt [2].

test for bug 1:
> sleep 10 && echo %
sets title to "sleep 10 && echo %<<"
> sleep 10 && echo %f
doesn't change the title at all

test for bug 2 (only urxvt):
> echo %f
39m%f
^^^^^----- output

Diff

 1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
 2index e26fef6d30d8a3f46e1fa4862c20626815743891..4701e46c5adf09990f450b3409c96d7198335590 100644
 3--- a/lib/termsupport.zsh
 4+++ b/lib/termsupport.zsh
 5@@ -27,7 +27,7 @@ function omz_termsupport_preexec {
 6   emulate -L zsh
 7   setopt extended_glob
 8   local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
 9-  title "$CMD" "%100>...>$2%<<"
10+  title "$CMD" "%100>...>${2:gs/%/%%}%<<"
11 }
12 
13 autoload -U add-zsh-hook