Browse code

avoid forking subshell to test if user is root

Suraj N. Kurapati authored on 09/01/2011 at 02:15:57
Showing 7 changed files
... ...
@@ -1,4 +1,4 @@
1
-if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
1
+if [ $UID -eq 0 ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
2 2
 
3 3
 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
4 4
 
... ...
@@ -1,4 +1,4 @@
1
-if [ "$(whoami)" = "root" ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
1
+if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
2 2
 
3 3
 PROMPT='%{$fg[$NCOLOR]%}%c ➤ %{$reset_color%}'
4 4
 RPROMPT='%{$fg[$NCOLOR]%}%p $(git_prompt_info)%{$reset_color%}'
... ...
@@ -1,4 +1,4 @@
1
-if [ "$(whoami)" = "root" ]; then NCOLOR="red"; else NCOLOR="white"; fi
1
+if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="white"; fi
2 2
 
3 3
 PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) '
4 4
 RPROMPT='[%*]'
... ...
@@ -5,7 +5,7 @@ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
5 5
 ZSH_THEME_GIT_PROMPT_CLEAN=""
6 6
 
7 7
 function prompt_char {
8
-	if [ "$(whoami)" = "root" ]; then echo "%{$fg[red]%}#%{$reset_color%}"; else echo $; fi
8
+	if [ $UID -eq 0 ]; then echo "%{$fg[red]%}#%{$reset_color%}"; else echo $; fi
9 9
 }
10 10
 
11 11
 PROMPT='%(?, ,%{$fg[red]%}FAIL%{$reset_color%}
... ...
@@ -1,6 +1,6 @@
1 1
 # ZSH Theme - Preview: http://dl.dropbox.com/u/1552408/Screenshots/2010-04-08-oh-my-zsh.png
2 2
 
3
-if [ "$(whoami)" = "root" ]; then NCOLOR="red"; else NCOLOR="green"; fi
3
+if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
4 4
 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
5 5
 
6 6
 PROMPT='%{$fg[$NCOLOR]%}%n%{$fg[green]%}@%m%{$reset_color%} %~ \
... ...
@@ -1,4 +1,4 @@
1
-if [ "$(whoami)" = "root" ]; then NCOLOR="red"; else NCOLOR="green"; fi
1
+if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
2 2
 
3 3
 PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) '
4 4
 RPROMPT='[%*]'
... ...
@@ -1,4 +1,4 @@
1
-if [ "$(whoami)" = "root" ]; then NCOLOR="red"; else NCOLOR="green"; fi
1
+if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
2 2
 
3 3
 PROMPT='
4 4
 %{$fg[$NCOLOR]%}%B%n@%m%b%{$reset_color%} %{$fg[white]%}%B${PWD/#$HOME/~}%b%{$reset_color%}