74177c5320b2a1b2f8c4c695c05984b57fd7c6ea

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Change all whoami calls for $USER variable

This avoid spawning additional processes, as the $USER variable will
**always** contain the current logged-in user.

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/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
 18index f5e44c66f500850daa234c407825493ad0ec58f9..e0b1773ada238a971ecc4d78294c145071ddc5a7 100644
 19--- a/plugins/systemadmin/systemadmin.plugin.zsh
 20+++ b/plugins/systemadmin/systemadmin.plugin.zsh
 21@@ -30,7 +30,7 @@ function retlog() {
 22 }
 23 
 24 alias ping='ping -c 5'
 25-alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
 26+alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $(pwd)."'
 27 alias path='echo -e ${PATH//:/\\n}'
 28 alias mkdir='mkdir -pv'
 29 # get top process eating memory
 30diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme
 31index aa3093f64139751b78f6264755128d32e003fb96..6869c8a20ae20203ded67bd33f1ee987af09bd19 100644
 32--- a/themes/adben.zsh-theme
 33+++ b/themes/adben.zsh-theme
 34@@ -89,9 +89,8 @@ function precmd {
 35 
 36 # Context: user@directory or just directory
 37 prompt_context () {
 38-    local user=`whoami`
 39-    if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 40-        echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
 41+    if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 42+        echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
 43     else
 44         echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
 45     fi
 46diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 47index 2b33c48bc7bc2cec58bad4ecff372026c2a023e1..7a62bd860802d3f093d28eb2387bd26f4e427ea1 100644
 48--- a/themes/agnoster.zsh-theme
 49+++ b/themes/agnoster.zsh-theme
 50@@ -60,10 +60,8 @@ prompt_end() {
 51 
 52 # Context: user@hostname (who am I and where am I)
 53 prompt_context() {
 54-  local user=`whoami`
 55-
 56-  if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 57-    prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
 58+  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 59+    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
 60   fi
 61 }
 62 
 63diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme
 64index 280794f2b83c33bf3c039e2fdb3a868b92d55ca2..c0a7fb5d0a9824cb17374cd90ee22262198803e9 100644
 65--- a/themes/flazz.zsh-theme
 66+++ b/themes/flazz.zsh-theme
 67@@ -1,4 +1,4 @@
 68-if [ "$(whoami)" = "root" ]
 69+if [ "$USER" = "root" ]
 70 then CARETCOLOR="red"
 71 else CARETCOLOR="blue"
 72 fi
 73diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme
 74index 08d13766585b414d92b7d4df2ceb66e179669810..7af44056f606654d564f839f36d14f8e60ed01b6 100644
 75--- a/themes/obraun.zsh-theme
 76+++ b/themes/obraun.zsh-theme
 77@@ -1,4 +1,4 @@
 78-if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
 79+if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
 80 
 81 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
 82 
 83diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme
 84index 5bded76a3e99bf06a895424a1ac955967fe3fe26..95af1e2ee3bf110fe16e03555526b12067fe4dd3 100644
 85--- a/themes/re5et.zsh-theme
 86+++ b/themes/re5et.zsh-theme
 87@@ -1,4 +1,4 @@
 88-if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
 89+if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
 90 
 91 local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
 92 
 93diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme
 94index 4bea20a1bd37cdc544daead93b798a72c180a47d..28befd01b5059b7973a16225fe00223c9e3914c0 100644
 95--- a/themes/sunrise.zsh-theme
 96+++ b/themes/sunrise.zsh-theme
 97@@ -10,7 +10,7 @@ Y=$fg_no_bold[yellow]
 98 B=$fg_no_bold[blue]
 99 RESET=$reset_color
100 
101-if [ "$(whoami)" = "root" ]; then
102+if [ "$USER" = "root" ]; then
103     PROMPTCOLOR="%{$R%}" PREFIX="-!-";
104 else
105     PROMPTCOLOR="" PREFIX="---";
106diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme
107index a44f295f4acd229833e20051c4c84a600d1dbb71..65448964dae05d79a0b6bf0c032af384762d9eaf 100644
108--- a/themes/ys.zsh-theme
109+++ b/themes/ys.zsh-theme
110@@ -33,7 +33,7 @@ ${git_info} \
111 %{$fg[white]%}[%*]
112 %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
113 
114-if [[ "$(whoami)" == "root" ]]; then
115+if [[ "$USER" == "root" ]]; then
116 PROMPT="
117 %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
118 %{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \