diff --git a/bash/bash_prompt.sh b/bash/bash_prompt.sh index a467c9c..c661fc2 100644 --- a/bash/bash_prompt.sh +++ b/bash/bash_prompt.sh @@ -2,30 +2,78 @@ angle="❯" NO_FORMAT="\033[0m" -C_SEAGREEN2="\033[38;5;83m" -C_INDIANRED1="\033[38;5;203m" -C_GREY89="\033[38;5;254m" +fg="\033[38;2;" +bg="\033[48;2;" + +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" == "root" ]]; then - char1_col="$C_SEAGREEN2"; - home_col="$C_INDIANRED1"; + angle1_col="$rad_red"; + home_col="$rad_red"; else - char1_col="$C_GREY89"; - home_col="$C_SEAGREEN2"; + angle1_col="$lime_green"; + home_col="$lime_green"; 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 [[ "$?" -eq "0" ]]; then - char4_col="$C_SEAGREEN2"; +if [[ $? -eq 0 ]]; then + angle2_col="$lime_green"; else - char4_col="$C_INDIANRED1"; + angle2_col="$rad_red"; 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 -e "$dir$char1_col$angle$NO_FORMAT$angle$char3_col$angle$char4_col$angle$NO_FORMAT" \ No newline at end of file +echo "$prompt" +#export PS1="$prompt" \ No newline at end of file