Improve bash prompt

This commit is contained in:
2024-07-14 12:35:03 -07:00
parent 81d9a970b9
commit 2cfb7893d0

View File

@@ -98,11 +98,14 @@
programs.bash = {
promptInit = ''
PROMPT_COLOR="1;31m"
((UID)) && PROMPT_COLOR="1;32m"
BASE_PROMPT="💜\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] "
BRANCH="\$(git branch --show-current 2>/dev/null)"
PS1="\n\[$(tput sc)\$([ -n "$BRANCH" ] && printf "%*s" $COLUMNS "$BRANCH")\$(tput rc)\]$BASE_PROMPT"
PS1="\[\e]0;\u@\h: \w\a\]" # window title
PS1+="\n"
PS1+="\$(printf \"%*s\" \$((\$COLUMNS + 9)) \"\[\e[1;33m\]\$(git branch --show-current 2>/dev/null)\")" # git branch
PS1+="\[\e[1G\]" # move cursor to beginning of line
PS1+="💜" # prompt symbol
PS1+="\[\033[1;$((UID ? 32 : 31))m\]" # prompt color
PS1+="[\u@\h:\w]\\$"
PS1+="\[\033[0m\] " # reset color
'';
};