Browse code

Refactor DISABLE_AUTO_TITLE to be more DRY

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