Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactor DISABLE_AUTO_TITLE to be more DRY

  • Loading branch information...
commit 0cc0915bf83c1915575182d1287abfc6dd3e6f3c 1 parent a3e9289
Renaud Morvan authored April 04, 2011

Showing 1 changed file with 6 additions and 9 deletions. Show diff stats Hide diff stats

  1. 15  lib/termsupport.zsh
15  lib/termsupport.zsh
@@ -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 17
 
17 18
 #Appears when you have the prompt
18 19
 function precmd {
19  
-  if [ "$DISABLE_AUTO_TITLE" != "true" ]; then
20  
-    title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
21  
-  fi
  20
+  title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
22 21
 }
23 22
 
24 23
 #Appears at the beginning of (and during) of command execution
25 24
 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
  25
+  emulate -L zsh
  26
+  setopt extended_glob
  27
+  local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
  28
+  title "$CMD" "%100>...>$2%<<"
32 29
 }

0 notes on commit 0cc0915

Please sign in to comment.
Something went wrong with that request. Please try again.