Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index bd0cf6ffe72864fc4a2610ce17ce1038d226aa7b..58c6203a0663374c1af46a0cafb4a05fcde1db8b 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -1,13 +1,21 @@
6-#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
7-#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
8-#Fully support screen, iterm, and probably most modern xterm and rxvt
9+# Set terminal window and tab/icon title
10+#
11+# usage: title short_tab_title [long_window_title]
12+#
13+# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
14+# Fully supports screen, iterm, and probably most modern xterm and rxvt
15+# (In screen, only short_tab_title is used)
16+# Limited support for Apple Terminal (Terminal can't set window and tab separately)
17 function title {
18- if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
19- return
20- fi
21+ [[ "$EMACS" == *term* ]] && return
22+
23+ # if $2 is unset use $1 as default
24+ # if it is set and empty, leave it as is
25+ : ${2=$1}
26+
27 if [[ "$TERM" == screen* ]]; then
28 print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
29- elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
30+ elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
31 print -Pn "\e]2;$2:q\a" #set window name
32 print -Pn "\e]1;$1:q\a" #set icon (=tab) name
33 fi
34@@ -18,6 +26,10 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
35
36 # Runs before showing the prompt
37 function omz_termsupport_precmd {
38+ if [[ $DISABLE_AUTO_TITLE == true ]]; then
39+ return
40+ fi
41+
42 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
43
44 # Notify Terminal.app of current directory using undocumented OSC sequence
45@@ -30,6 +42,10 @@ function omz_termsupport_precmd {
46
47 # Runs before executing the command
48 function omz_termsupport_preexec {
49+ if [[ $DISABLE_AUTO_TITLE == true ]]; then
50+ return
51+ fi
52+
53 emulate -L zsh
54 setopt extended_glob
55