7f75bb90e326fdb39de37c14a0813e52801b1bba

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #3223 from mcornella/use-special-vars

Use special variables where we can

Diff

  1diff --git a/lib/completion.zsh b/lib/completion.zsh
  2index 83b6efb66d606b43869994741d0c897856956fd9..3a19a4eba17a99faf2481a85110bea4f5937b9e7 100644
  3--- a/lib/completion.zsh
  4+++ b/lib/completion.zsh
  5@@ -27,9 +27,9 @@ zstyle ':completion:*:*:*:*:*' menu select
  6 zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  7 if [ "$OSTYPE[0,7]" = "solaris" ]
  8 then
  9-  zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm"
 10+  zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
 11 else
 12-  zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
 13+  zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
 14 fi
 15 
 16 # disable named-directories autocompletion
 17diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
 18index 504d7ec14b3817631b2aff8d36fd8a6c8d227c24..d101cfcae6a435ac0d78398f23cb1aac809a0efc 100644
 19--- a/plugins/dirhistory/dirhistory.plugin.zsh
 20+++ b/plugins/dirhistory/dirhistory.plugin.zsh
 21@@ -3,7 +3,7 @@
 22 #   that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
 23 # 
 24 
 25-dirhistory_past=(`pwd`)
 26+dirhistory_past=($PWD)
 27 dirhistory_future=()
 28 export dirhistory_past
 29 export dirhistory_future
 30@@ -50,7 +50,7 @@ function push_future() {
 31 
 32 # Called by zsh when directory changes
 33 function chpwd() {
 34-  push_past `pwd`
 35+  push_past $PWD
 36   # If DIRHISTORY_CD is not set...
 37   if [[ -z "${DIRHISTORY_CD+x}" ]]; then
 38     # ... clear future.
 39@@ -73,7 +73,7 @@ function dirhistory_back() {
 40   pop_past cw 
 41   if [[ "" == "$cw" ]]; then
 42     # Someone overwrote our variable. Recover it.
 43-    dirhistory_past=(`pwd`)
 44+    dirhistory_past=($PWD)
 45     return
 46   fi
 47 
 48diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
 49index 1b23b5d427937f103ec948a09735b63952fbf8ab..b16814fe4d12b9935a046e745ab46169090c3446 100644
 50--- a/plugins/jump/jump.plugin.zsh
 51+++ b/plugins/jump/jump.plugin.zsh
 52@@ -14,12 +14,12 @@ jump() {
 53 
 54 mark() {
 55 	if (( $# == 0 )); then
 56-		MARK=$(basename "$(pwd)")
 57+		MARK=$(basename "$PWD")
 58 	else
 59 		MARK="$1"
 60 	fi
 61-	if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then
 62-		mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK"
 63+	if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
 64+		mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK"
 65 	fi
 66 }
 67 
 68diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh
 69index d85c8877777a44e57924eda79315fdfae38c9de0..ded3336a738932d250360da7819bc4a1e9f93aa6 100644
 70--- a/plugins/pow/pow.plugin.zsh
 71+++ b/plugins/pow/pow.plugin.zsh
 72@@ -21,13 +21,13 @@
 73 
 74 rack_root(){
 75   setopt chaselinks
 76-  local orgdir="$(pwd)"
 77-  local basedir="$(pwd)"
 78+  local orgdir="$PWD"
 79+  local basedir="$PWD"
 80 
 81   while [[ $basedir != '/' ]]; do
 82     test -e "$basedir/config.ru" && break
 83     builtin cd ".." 2>/dev/null
 84-    basedir="$(pwd)"
 85+    basedir="$PWD"
 86   done
 87 
 88   builtin cd "$orgdir" 2>/dev/null
 89@@ -56,7 +56,7 @@ kapow(){
 90 compctl -W ~/.pow -/ kapow
 91 
 92 powit(){
 93-  local basedir="$(pwd)"
 94+  local basedir="$PWD"
 95   local vhost=$1
 96   [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
 97   if [ ! -h ~/.pow/$vhost ]
 98diff --git a/plugins/profiles/profiles.plugin.zsh b/plugins/profiles/profiles.plugin.zsh
 99index 8faae6b53290b9fa9fb37255fb0159d142327df7..4b3d6a852bf66262aa731925dd2e467b097cd122 100644
100--- a/plugins/profiles/profiles.plugin.zsh
101+++ b/plugins/profiles/profiles.plugin.zsh
102@@ -2,7 +2,7 @@
103 
104 # This will look for a custom profile for the local machine and each domain or
105 # subdomain it belongs to. (e.g. com, example.com and foo.example.com)
106-parts=(${(s:.:)$(hostname)})
107+parts=(${(s:.:)$HOST})
108 for i in {${#parts}..1}; do
109   profile=${(j:.:)${parts[$i,${#parts}]}}
110   file=$ZSH_CUSTOM/profiles/$profile
111diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
112index ef6da5bd3cb6e6447e59c224fc8a158ecc1ac590..ba281d7909499529a6fcbd4e988078b2f32a22d5 100644
113--- a/plugins/svn/svn.plugin.zsh
114+++ b/plugins/svn/svn.plugin.zsh
115@@ -77,7 +77,7 @@ function svn_dirty() {
116 
117 function svn_dirty_choose_pwd () {
118   if in_svn; then
119-    root=`pwd`
120+    root=$PWD
121     if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
122       # Grep exits with 0 when "One or more lines were selected", return "dirty".
123       echo $1
124diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
125index f5e44c66f500850daa234c407825493ad0ec58f9..4ae70dfa751dc124c3cb47b83eb1f6c57c34b203 100644
126--- a/plugins/systemadmin/systemadmin.plugin.zsh
127+++ b/plugins/systemadmin/systemadmin.plugin.zsh
128@@ -30,7 +30,7 @@ function retlog() {
129 }
130 
131 alias ping='ping -c 5'
132-alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
133+alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."'
134 alias path='echo -e ${PATH//:/\\n}'
135 alias mkdir='mkdir -pv'
136 # get top process eating memory
137diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh
138index 5142f1f9b586607ec17355c33161ef99c9c486f8..b0b9414cd2aac90e3403418c6b3e38e381cbcc6b 100644
139--- a/plugins/vim-interaction/vim-interaction.plugin.zsh
140+++ b/plugins/vim-interaction/vim-interaction.plugin.zsh
141@@ -9,7 +9,7 @@ function resolveFile
142   if [ -f "$1" ]; then
143     echo $(readlink -f "$1")
144   elif [[ "${1#/}" == "$1" ]]; then
145-    echo "$(pwd)/$1"
146+    echo "$PWD/$1"
147   else
148     echo $1
149   fi
150diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme
151index aa3093f64139751b78f6264755128d32e003fb96..6869c8a20ae20203ded67bd33f1ee987af09bd19 100644
152--- a/themes/adben.zsh-theme
153+++ b/themes/adben.zsh-theme
154@@ -89,9 +89,8 @@ function precmd {
155 
156 # Context: user@directory or just directory
157 prompt_context () {
158-    local user=`whoami`
159-    if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
160-        echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
161+    if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
162+        echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
163     else
164         echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
165     fi
166diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
167index 2b33c48bc7bc2cec58bad4ecff372026c2a023e1..7a62bd860802d3f093d28eb2387bd26f4e427ea1 100644
168--- a/themes/agnoster.zsh-theme
169+++ b/themes/agnoster.zsh-theme
170@@ -60,10 +60,8 @@ prompt_end() {
171 
172 # Context: user@hostname (who am I and where am I)
173 prompt_context() {
174-  local user=`whoami`
175-
176-  if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
177-    prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
178+  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
179+    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
180   fi
181 }
182 
183diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
184index 718977d904d512eeafe1b9d9ec6bd0c0f34c3d43..8891287585152e18aa193edc1c4c53428659dd47 100644
185--- a/themes/candy-kingdom.zsh-theme
186+++ b/themes/candy-kingdom.zsh-theme
187@@ -13,7 +13,7 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
188 }
189 
190 function box_name {
191-    [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
192+    [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
193 }
194 
195 PROMPT='
196diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme
197index 0a5e9265bd680e628c2da9ae61b5ae37159d1214..58d9f88a9c0ed2de78a3b9ab8f769caa6d312db4 100644
198--- a/themes/dieter.zsh-theme
199+++ b/themes/dieter.zsh-theme
200@@ -21,7 +21,7 @@ local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}"
201 
202 # Hostname part.  compressed and colorcoded per host_repr array
203 # if not found, regular hostname in default color
204-local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}"
205+local host="@${host_repr[$HOST]:-$HOST}%{$reset_color%}"
206 
207 # Compacted $PWD
208 local pwd="%{$fg[blue]%}%c%{$reset_color%}"
209diff --git a/themes/fino-time.zsh-theme b/themes/fino-time.zsh-theme
210index 901c4d99fdfe730a91ed92e95860dea1a8cbcf67..67b6b6e08edd45f5069aeb76c19dcd37c314930a 100644
211--- a/themes/fino-time.zsh-theme
212+++ b/themes/fino-time.zsh-theme
213@@ -21,7 +21,7 @@ function prompt_char {
214 }
215 
216 function box_name {
217-    [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
218+    [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
219 }
220 
221 
222diff --git a/themes/fino.zsh-theme b/themes/fino.zsh-theme
223index 411dec9b9dedd052ffa2c15ed6d275283da1443f..50d41e89976ed0f7062523a52c1701218a60d42f 100644
224--- a/themes/fino.zsh-theme
225+++ b/themes/fino.zsh-theme
226@@ -17,7 +17,7 @@ function prompt_char {
227 }
228 
229 function box_name {
230-    [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
231+    [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
232 }
233 
234 local ruby_env=''
235diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme
236index 280794f2b83c33bf3c039e2fdb3a868b92d55ca2..c0a7fb5d0a9824cb17374cd90ee22262198803e9 100644
237--- a/themes/flazz.zsh-theme
238+++ b/themes/flazz.zsh-theme
239@@ -1,4 +1,4 @@
240-if [ "$(whoami)" = "root" ]
241+if [ "$USER" = "root" ]
242 then CARETCOLOR="red"
243 else CARETCOLOR="blue"
244 fi
245diff --git a/themes/kardan.zsh-theme b/themes/kardan.zsh-theme
246index fd6586a9d70ce03e7fe20bdc7921d66b94e3576e..9a3d59109ac31b8199f46712cb43759cdb56a6c4 100644
247--- a/themes/kardan.zsh-theme
248+++ b/themes/kardan.zsh-theme
249@@ -1,7 +1,7 @@
250 # Simple theme based on my old zsh settings.
251 
252 function get_host {
253-	echo '@'`hostname`''
254+	echo '@'$HOST
255 }
256 
257 PROMPT='> '
258diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme
259index ef4c6d740d8abd92e0fb647906c172050748caa0..a7599c8f52ce077e2b4aa7dd223f86a528cec1f4 100644
260--- a/themes/michelebologna.zsh-theme
261+++ b/themes/michelebologna.zsh-theme
262@@ -17,7 +17,7 @@ USERNAME_NORMAL_COLOR=$WHITE
263 USERNAME_ROOT_COLOR=$RED
264 HOSTNAME_NORMAL_COLOR=$BLUE
265 # uncomment next line if you want auto-generated hostname color
266-#for i in `hostname`; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
267+#for i in $HOST; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
268 HOSTNAME_ROOT_COLOR=$RED
269 HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR)
270 CURRENT_DIR_COLOR=$CYAN
271diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme
272index 08d13766585b414d92b7d4df2ceb66e179669810..7af44056f606654d564f839f36d14f8e60ed01b6 100644
273--- a/themes/obraun.zsh-theme
274+++ b/themes/obraun.zsh-theme
275@@ -1,4 +1,4 @@
276-if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
277+if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
278 
279 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
280 
281diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme
282index 5bded76a3e99bf06a895424a1ac955967fe3fe26..95af1e2ee3bf110fe16e03555526b12067fe4dd3 100644
283--- a/themes/re5et.zsh-theme
284+++ b/themes/re5et.zsh-theme
285@@ -1,4 +1,4 @@
286-if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
287+if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
288 
289 local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
290 
291diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme
292index 4bea20a1bd37cdc544daead93b798a72c180a47d..28befd01b5059b7973a16225fe00223c9e3914c0 100644
293--- a/themes/sunrise.zsh-theme
294+++ b/themes/sunrise.zsh-theme
295@@ -10,7 +10,7 @@ Y=$fg_no_bold[yellow]
296 B=$fg_no_bold[blue]
297 RESET=$reset_color
298 
299-if [ "$(whoami)" = "root" ]; then
300+if [ "$USER" = "root" ]; then
301     PROMPTCOLOR="%{$R%}" PREFIX="-!-";
302 else
303     PROMPTCOLOR="" PREFIX="---";
304diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme
305index a44f295f4acd229833e20051c4c84a600d1dbb71..0171391001a171b1f3e8f1bb0ae09d339b7d963a 100644
306--- a/themes/ys.zsh-theme
307+++ b/themes/ys.zsh-theme
308@@ -8,7 +8,7 @@
309 
310 # Machine name.
311 function box_name {
312-    [ -f ~/.box-name ] && cat ~/.box-name || hostname
313+    [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
314 }
315 
316 # Directory info.
317@@ -33,7 +33,7 @@ ${git_info} \
318 %{$fg[white]%}[%*]
319 %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
320 
321-if [[ "$(whoami)" == "root" ]]; then
322+if [[ "$USER" == "root" ]]; then
323 PROMPT="
324 %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
325 %{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \