]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
zsh/rc: Escape non printable characters when setting window titles.
authorSimon Ruderich <simon@ruderich.org>
Mon, 16 Aug 2010 15:34:48 +0000 (17:34 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 16 Aug 2010 15:34:48 +0000 (17:34 +0200)
zsh/rc

diff --git a/zsh/rc b/zsh/rc
index 1f218f7b2f6eb2a7b898c75f14142f130930fab2..df4d35762d70332605566e5ced7a2ee51d302d83 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -411,14 +411,16 @@ if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then
         window_reset=
     }
 
-    # Sets the window title. Works with screen, xterm and rxvt.
+    # Sets the window title. Works with screen, xterm and rxvt. (V) escapes
+    # all non-printable characters. Thanks to Mikachu in #zsh on Freenode
+    # (2010-08-07 17:09 CEST).
     if [[ $TERM == screen* ]]; then
         window_title() {
-            print -n "\ek$1\e\\"
+            print -n "\ek${(V)1}\e\\"
         }
     elif [[ $TERM == xterm* || $TERM == rxvt* ]]; then
         window_title() {
-            print -n "\e]2;$1\e\\"
+            print -n "\e]2;${(V)1}\e\\"
         }
     else
         # Fallback if another TERM is used.