.prefix: Change the way alternate shells are presented

Now they have a different bracket (parenthesis) and a different-colored PWD, even in SSH sessions
This commit is contained in:
Salt 2018-10-07 00:15:04 -05:00
parent ca5cc3de19
commit 51975d3326

View File

@ -85,32 +85,30 @@ _ps1() {
exitcode="$?"
r="\e[0m"
fg_blue="\e[34m"
fg_cyan="\e[36m"
fg_red="\e[31m"
fg_green="\e[32m"
fg_yellow="\e[33m"
fg_grey="\e[37m"
fg_bold="\e[1m"
# Change PWD color in SSH sessions
hostname_prefix="${fg_blue}"
# Add hostname prefix in SSH sessions
if [ "$SSH_CLIENT" ]; then
# Also add the machine's hostname
hostname_prefix="${fg_bold}${fg_red}`hostname`${r}${fg_red}:"
prefix="${fg_bold}${fg_red}`hostname`${r}${fg_red}:"
fi
# Change $ color depending on shell
cashcolor="${fg_green}"
# Change PWD color depending on the shell
case $0 in
bash)
cashcolor="${fg_blue}"
prefix="${prefix}${fg_yellow}"
;;
ksh)
cashcolor="${fg_yellow}"
prefix="${prefix}${fg_green}"
;;
sh)
cashcolor="${fg_grey}"
prefix="${prefix}${fg_grey}"
;;
*)
cashcolor="${fg_green}"
;;
esac
# Show the tilde instead of $HOME
@ -120,7 +118,7 @@ _ps1() {
if ! [ "$exitcode" = "0" ]; then
fail="${fg_bold}${fg_red}?"
fi
printf "[${hostname_prefix}${cpwd}${r}]${fail}${r}${cashcolor}\$${r} "
printf "(${prefix}${cpwd}${r})${fail}${r}${fg_green}\$${r} "
}
if ! [ "$ZSH_NAME" ]; then