.profile: Update variable names in our PS1 command to avoid clobbering
This commit is contained in:
parent
a3f24f4b79
commit
d2900fee75
32
.profile
32
.profile
@ -331,59 +331,59 @@ _ps1bash() {
|
|||||||
fg_bold="\[\e[1m\]"
|
fg_bold="\[\e[1m\]"
|
||||||
|
|
||||||
# Add hostname prefix in SSH sessions
|
# Add hostname prefix in SSH sessions
|
||||||
unset prefix
|
unset _prefix
|
||||||
# Alert if in an SSH session
|
# Alert if in an SSH session
|
||||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
prefix="${fg_bold}${fg_red}$(hostname -s)${r}${fg_red}:${r}${prefix}"
|
_prefix="${fg_bold}${fg_red}$(hostname -s)${r}${fg_red}:${r}${_prefix}"
|
||||||
elif [ "$USER" != "salt" ]; then
|
elif [ "$USER" != "salt" ]; then
|
||||||
prefix="${fg_bold}${fg_yellow}$USER${r}${fg_yellow}:${r}${prefix}"
|
_prefix="${fg_bold}${fg_yellow}$USER${r}${fg_yellow}:${r}${_prefix}"
|
||||||
fi
|
fi
|
||||||
# Change PWD color depending on the shell
|
# Change PWD color depending on the shell
|
||||||
case $0 in
|
case $0 in
|
||||||
*bash)
|
*bash)
|
||||||
prefix="${prefix}${fg_blue}"
|
_prefix="${_prefix}${fg_blue}"
|
||||||
;;
|
;;
|
||||||
*ksh)
|
*ksh)
|
||||||
prefix="${prefix}${fg_green}"
|
_prefix="${_prefix}${fg_green}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# Show the tilde instead of $HOME
|
# Show the tilde instead of $HOME
|
||||||
cpwd='\w'
|
_cpwd='\w'
|
||||||
# Show read-only status in certain directories
|
# Show read-only status in certain directories
|
||||||
if [ "$UID" = 0 ]; then
|
if [ "$UID" = 0 ]; then
|
||||||
# Root gets the usual "#" prompt
|
# Root gets the usual "#" prompt
|
||||||
prompt="${fg_red}#${r}"
|
_prompt="${fg_red}#${r}"
|
||||||
elif ! [ -d "$PWD" ]; then
|
elif ! [ -d "$PWD" ]; then
|
||||||
# Something very bad has happened to our PWD, probably got deleted
|
# Something very bad has happened to our PWD, probably got deleted
|
||||||
prompt="${bg_red}${fg_black}!${r}"
|
_prompt="${bg_red}${fg_black}!${r}"
|
||||||
elif ! [ -r "$PWD" ]; then
|
elif ! [ -r "$PWD" ]; then
|
||||||
# Guess we lost privileges
|
# Guess we lost privileges
|
||||||
prompt="${fg_red}"'$'"${r}"
|
_prompt="${fg_red}"'$'"${r}"
|
||||||
elif ! [ -x "$PWD" ]; then
|
elif ! [ -x "$PWD" ]; then
|
||||||
# Missing execution perms
|
# Missing execution perms
|
||||||
if [ -w "$PWD" ]; then
|
if [ -w "$PWD" ]; then
|
||||||
# Fixable
|
# Fixable
|
||||||
prompt="${bg_blue}${fg_black}"'$'"${r}"
|
_prompt="${bg_blue}${fg_black}"'$'"${r}"
|
||||||
else
|
else
|
||||||
# Unfixable
|
# Unfixable
|
||||||
prompt="${bg_yellow}${fg_black}"'$'"${r}"
|
_prompt="${bg_yellow}${fg_black}"'$'"${r}"
|
||||||
fi
|
fi
|
||||||
elif ! [ -w "$PWD" ]; then
|
elif ! [ -w "$PWD" ]; then
|
||||||
# Can't write is really common but also good to know
|
# Can't write is really common but also good to know
|
||||||
prompt="${fg_magenta}"'~'"${r}"
|
_prompt="${fg_magenta}"'~'"${r}"
|
||||||
else
|
else
|
||||||
# Otherwise we should be fine
|
# Otherwise we should be fine
|
||||||
prompt="${fg_green}"'$'"${r}"
|
_prompt="${fg_green}"'$'"${r}"
|
||||||
fi
|
fi
|
||||||
# Alert us if the last command failed
|
# Alert us if the last command failed
|
||||||
unset fail
|
unset _fail
|
||||||
if ! [ "$exitcode" = "0" ]; then
|
if ! [ "$exitcode" = "0" ]; then
|
||||||
fail="${fg_bold}${fg_red}?"
|
_fail="${fg_bold}${fg_red}?"
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=2059
|
# shellcheck disable=2059
|
||||||
PS1="[${prefix}${cpwd}${r}]${fail}${r}${prompt}${r} "
|
PS1="[${_prefix}${_cpwd}${r}]${_fail}${r}${_prompt}${r} "
|
||||||
}
|
}
|
||||||
|
|
||||||
# And export our PS1
|
# And export our PS1
|
||||||
|
Loading…
Reference in New Issue
Block a user