.profile: Change $ color depending on current shell

This commit is contained in:
Salt 2018-10-03 22:50:23 -05:00
parent 09227227f5
commit e12729f5ab

View File

@ -85,6 +85,8 @@ _ps1() {
fg_blue="\e[34m"
fg_red="\e[31m"
fg_green="\e[32m"
fg_yellow="\e[33m"
fg_grey="\e[37m"
fg_bold="\e[1m"
hostname_prefix="${fg_blue}"
@ -93,6 +95,22 @@ _ps1() {
# Also add the machine's hostname
hostname_prefix="${fg_bold}${fg_red}`hostname`${r}${fg_red}:"
fi
# Change $ color depending on shell
cashcolor="${fg_green}"
case $0 in
bash)
cashcolor="${fg_blue}"
;;
ksh)
cashcolor="${fg_yellow}"
;;
sh)
cashcolor="${fg_grey}"
;;
*)
cashcolor="${fg_green}"
;;
esac
# Show the tilde instead of $HOME
cpwd="${PWD/#$HOME/\~}"
# Alert us if the last command failed
@ -100,7 +118,7 @@ _ps1() {
if ! [ "$exitcode" = "0" ]; then
fail="${fg_bold}${fg_red}?"
fi
printf "[${hostname_prefix}${cpwd}${r}]${fail}${r}${fg_green}\$${r} "
printf "[${hostname_prefix}${cpwd}${r}]${fail}${r}${cashcolor}\$${r} "
}
if ! [ "$ZSH_NAME" ]; then