Browse Source

Fix title setting script

I just copied and simplified the one from grml-zsh-config. The old one
had problems when we run commands like date +%s since the % or other
characters break the interpretation.
Thomas Dy 9 years ago
parent
commit
9a7d98bb75
1 changed files with 9 additions and 3 deletions
  1. 9 3
      .zsh/title.zsh

+ 9 - 3
.zsh/title.zsh

@@ -1,8 +1,14 @@
+function set_title () {
+    printf '%s%s%s' $'\e]0;' "$@" $'\a'
+}
+
 case $TERM in
-  termite|*xterm*|rxvt|rxvt-unicode|rxvt-256color|rxvt-unicode-256color|(dt|k|E)term)
+  (xterm*|rxvt*)
     precmd () {
-      print -Pn "\e]0;%n@%M: %~\a"
+      set_title ${(%):-"%n@%m: %~"}
+    }
+    preexec () {
+      set_title "${(%):-"%n@%m: "}" "$1"
     }
-    preexec () { print -Pn "\e]0;%n@%M: %~ ($1)\a" }
     ;;
 esac