0cc0915bf83c1915575182d1287abfc6dd3e6f3c

Author
Renaud (Nel) Morvan <nel@w3fu.com>
Committer
Renaud (Nel) Morvan <nel@w3fu.com>
Date

Message

Refactor DISABLE_AUTO_TITLE to be more DRY

Diff

 1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
 2index 42bbb9ef2d2dacbacad9f6a0832f6b76b110dcfb..3152751e44b23f5b223eeb796e03a4fe08aff107 100644
 3--- a/lib/termsupport.zsh
 4+++ b/lib/termsupport.zsh
 5@@ -3,6 +3,7 @@
 6 #Fully support screen, iterm, and probably most modern xterm and rxvt
 7 #Limited support for Apple Terminal (Terminal can't set window or tab separately)
 8 function title {
 9+  [ "$DISABLE_AUTO_TITLE" != "true" ] || return
10   if [[ $TERM =~ "^screen" ]]; then 
11     print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
12   elif [[ ($TERM =~ "^xterm") ]] || [[ ($TERM == "rxvt") ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
13@@ -16,17 +17,13 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
14 
15 #Appears when you have the prompt
16 function precmd {
17-  if [ "$DISABLE_AUTO_TITLE" != "true" ]; then
18-    title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
19-  fi
20+  title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
21 }
22 
23 #Appears at the beginning of (and during) of command execution
24 function preexec {
25-  if [ "$DISABLE_AUTO_TITLE" != "true" ]; then
26-    emulate -L zsh
27-    setopt extended_glob
28-    local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
29-    title "$CMD" "%100>...>$2%<<"
30-  fi
31+  emulate -L zsh
32+  setopt extended_glob
33+  local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
34+  title "$CMD" "%100>...>$2%<<"
35 }