Update bash/bash_prompt.sh

This commit is contained in:
Candifloss 2024-08-13 11:15:32 +00:00
parent 9bcb8d41ba
commit 6a3db2608d

View File

@ -2,30 +2,78 @@ angle=""
NO_FORMAT="\033[0m" NO_FORMAT="\033[0m"
C_SEAGREEN2="\033[38;5;83m" fg="\033[38;2;"
C_INDIANRED1="\033[38;5;203m" bg="\033[48;2;"
C_GREY89="\033[38;5;254m"
function col() {
red="$1"
grn="$2"
blu="$3"
if [[ "$4" == "b" ]]; then
echo "$bg$red;$grn;$blu"m
else
echo "$fg$red;$grn;$blu"m
fi
}
rad_red="$(col 255 53 94)"
vsoft_red="$(col 237 137 157)"
lime_green="$(col 54 178 91)"
gray="$(col 70 70 70)"
mod_blue="$(col 49 142 193)"
dark_cyan="$(col 0 139 139)"
strong_orng="$(col 193 79 29)"
#If user is root #If user is root
if [[ "$USER" == "root" ]]; then if [[ "$USER" == "root" ]]; then
char1_col="$C_SEAGREEN2"; angle1_col="$rad_red";
home_col="$C_INDIANRED1"; home_col="$rad_red";
else else
char1_col="$C_GREY89"; angle1_col="$lime_green";
home_col="$C_SEAGREEN2"; home_col="$lime_green";
fi fi
dir=$(pwd)
git_branch=$(git status 2>/dev/null | cut -d" " -f3 | sd "\n.*" "")
if [[ -n $git_branch ]]; then
repo="$(git rev-parse --show-toplevel)"
if [[ $git_branch == "main" ]]; then
branch_col="$strong_orng"
else
branch_col="$gray"
fi
dir="$(echo $dir | sd "$repo/" "$(basename $repo) $branch_col󰊢 $gray:")"
angle3_col="$dark_cyan";
else
angle3_col="$gray";
fi
dir="$(echo $dir | sd "^$HOME" "$home_col~$gray")"
case "$SHELL" in
"/bin/bash")
shell_char=""
;;
"/usr/bin/zsh")
shell_char="󰰶"
;;
"/usr/bin/fish")
shell_char=""
;;
*)
shell_char="󱆃"
esac
#If previous commant was successful #If previous commant was successful
if [[ "$?" -eq "0" ]]; then if [[ $? -eq 0 ]]; then
char4_col="$C_SEAGREEN2"; angle2_col="$lime_green";
else else
char4_col="$C_INDIANRED1"; angle2_col="$rad_red";
fi fi
char3_col="$C_SEAGREEN2";
dir=$(pwd | sd "$HOME" "$home_col~$NO_FORMAT") prompt="$gray$shell_char $gray$dir$angle1_col$angle$angle2_col$angle$angle3_col$angle $NO_FORMAT"
prompt="$dir" echo "$prompt"
#export PS1="$prompt"
echo -e "$dir$char1_col$angle$NO_FORMAT$angle$char3_col$angle$char4_col$angle$NO_FORMAT"