]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - zsh/rc
zsh/rc: Escape non printable characters when setting window titles.
[config/dotfiles.git] / zsh / rc
diff --git a/zsh/rc b/zsh/rc
index 643d908d647ea3b1544895e1946ec0d3420238e6..df4d35762d70332605566e5ced7a2ee51d302d83 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -246,7 +246,7 @@ fi
 
 # Set the prompt. A two line prompt is used. On the top left the current
 # working directory is displayed, on the right vcs_info (if available). On the
-# bottom left current username and host is shown, the exit code of the last
+# bottom left current user name and host is shown, the exit code of the last
 # command if it wasn't 0, the number of running jobs if not 0.
 #
 # The prompt is in green and blue to make easily detectable, the error exit
@@ -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.