4fc6dccb4286828c7cd53d3612ec69b0c0d9aaf2

Author
Andrew Janke <janke@pobox.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

term: Move DISABLE_AUTO_TITLE check to hooks

Move the DISABLE_AUTO_TITLE check from title() to the preX hook
functions that call it, to allow the title() function to be used
directly by user or other callers.

Diff

 1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
 2index bd0cf6ffe72864fc4a2610ce17ce1038d226aa7b..2fa61c431d0df62a24a50d7e0335a8419d1e363a 100644
 3--- a/lib/termsupport.zsh
 4+++ b/lib/termsupport.zsh
 5@@ -1,8 +1,16 @@
 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+  if [[ $2 == "" ]]; then
20+    2="$1"
21+  fi
22+  if [[ "$EMACS" == *term* ]]; then
23     return
24   fi
25   if [[ "$TERM" == screen* ]]; then
26@@ -18,6 +26,10 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
27 
28 # Runs before showing the prompt
29 function omz_termsupport_precmd {
30+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
31+    return
32+  fi
33+
34   title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
35 
36   # Notify Terminal.app of current directory using undocumented OSC sequence
37@@ -30,6 +42,10 @@ function omz_termsupport_precmd {
38 
39 # Runs before executing the command
40 function omz_termsupport_preexec {
41+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
42+    return
43+  fi
44+
45   emulate -L zsh
46   setopt extended_glob
47