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.
@@ -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