dotfiles/bash/bash_prompt.sh

31 lines
606 B
Bash
Raw Normal View History

angle=""
NO_FORMAT="\033[0m"
C_SEAGREEN2="\033[38;5;83m"
C_INDIANRED1="\033[38;5;203m"
C_GREY89="\033[38;5;254m"
#If user is root
if [[ "$USER" == "root" ]]; then
char1_col="$C_SEAGREEN2";
home_col="$C_INDIANRED1";
else
char1_col="$C_GREY89";
home_col="$C_SEAGREEN2";
fi
#If previous commant was successful
if [[ "$?" -eq "0" ]]; then
char4_col="$C_SEAGREEN2";
else
char4_col="$C_INDIANRED1";
fi
char3_col="$C_SEAGREEN2";
dir=$(pwd | sd "$HOME" "$home_col~$NO_FORMAT")
prompt="$dir"
echo -e "$dir$char1_col$angle$NO_FORMAT$angle$char3_col$angle$char4_col$angle$NO_FORMAT"