Browse Source

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.
Andrew Janke 10 years ago
parent
commit
4fc6dccb42
1 changed files with 20 additions and 4 deletions
  1. 20 4
      lib/termsupport.zsh

+ 20 - 4
lib/termsupport.zsh

@@ -1,8 +1,16 @@
-#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
-#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
-#Fully support screen, iterm, and probably most modern xterm and rxvt
+# Set terminal window and tab/icon title
+#
+# usage: title short_tab_title [long_window_title]
+#
+# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
+# Fully supports screen, iterm, and probably most modern xterm and rxvt
+# (In screen, only short_tab_title is used)
+# Limited support for Apple Terminal (Terminal can't set window and tab separately)
 function title {
-  if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
+  if [[ $2 == "" ]]; then
+    2="$1"
+  fi
+  if [[ "$EMACS" == *term* ]]; then
     return
   fi
   if [[ "$TERM" == screen* ]]; then
@@ -18,6 +26,10 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
 
 # Runs before showing the prompt
 function omz_termsupport_precmd {
+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
+    return
+  fi
+
   title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
 
   # Notify Terminal.app of current directory using undocumented OSC sequence
@@ -30,6 +42,10 @@ function omz_termsupport_precmd {
 
 # Runs before executing the command
 function omz_termsupport_preexec {
+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
+    return
+  fi
+
   emulate -L zsh
   setopt extended_glob