Test if dircolors or whoami commands exists before calling them
This commit is contained in:
parent
7923da48f3
commit
febd0c2503
13
.zshrc
13
.zshrc
@ -59,6 +59,10 @@ find_up () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command-exists () {
|
||||||
|
return [[ -n $commands[$1] ]];
|
||||||
|
}
|
||||||
|
|
||||||
#---------------------------------- Tab completion ----------------------------
|
#---------------------------------- Tab completion ----------------------------
|
||||||
|
|
||||||
# Force a reload of completion system if nothing matched; this fixes installing
|
# Force a reload of completion system if nothing matched; this fixes installing
|
||||||
@ -215,7 +219,10 @@ prompt_root() {
|
|||||||
|
|
||||||
# Different username
|
# Different username
|
||||||
prompt_user() {
|
prompt_user() {
|
||||||
local user=$(whoami)
|
local user=$USER
|
||||||
|
if command-exists whoami && [[ -z $user ]] then
|
||||||
|
user=$(whoami)
|
||||||
|
fi
|
||||||
if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then
|
if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then
|
||||||
print -n $user
|
print -n $user
|
||||||
fi
|
fi
|
||||||
@ -334,7 +341,9 @@ case $(uname -s) in
|
|||||||
LSOPTS="${LSOPTS} -G"
|
LSOPTS="${LSOPTS} -G"
|
||||||
;;
|
;;
|
||||||
Linux)
|
Linux)
|
||||||
eval "$(dircolors -b)"
|
if command-exists dircolors; then
|
||||||
|
eval "$(dircolors -b)"
|
||||||
|
fi
|
||||||
LSOPTS="$LSOPTS --color=auto"
|
LSOPTS="$LSOPTS --color=auto"
|
||||||
LLOPTS="$LLOPTS --color=always" # so | less is colored
|
LLOPTS="$LLOPTS --color=always" # so | less is colored
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user