diff options
| author | Caroline Larimore <caroline@larimo.re> | 2024-08-15 14:11:13 -0700 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2024-08-15 14:11:13 -0700 |
| commit | a714954d60b9b0a9b4b99d93d2caef72edec6b87 (patch) | |
| tree | 706f88c9c24b5402fe228785d01e8b8eb06c3c23 /core/bash/prompt.sh | |
| parent | d1140c1ea30ac817c4722856ea318b57bfb48da4 (diff) | |
core: set bash prompt
Diffstat (limited to 'core/bash/prompt.sh')
| -rw-r--r-- | core/bash/prompt.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/core/bash/prompt.sh b/core/bash/prompt.sh new file mode 100644 index 0000000..56bde5b --- /dev/null +++ b/core/bash/prompt.sh @@ -0,0 +1,66 @@ +if [[ "$TERM" == "xterm-kitty" ]]; then + source "$(dirname "${BASH_SOURCE[0]}")/git-prompt.sh" + + function prompt.bubble { + printf '\[\e[49m\e[38;5;237m\]◖\[\e[48;5;237m\e[39m\]%s\[\e[0m\e[49m\e[38;5;237m\]◗\[\e[0m\]' "$@"; + } + + function prompt.bubble_squared { + printf '\[\e[48;5;237m\e[39m\] %s\[\e[0m\e[49m\e[38;5;237m\]◗\[\e[0m\]' "$@"; + } + + function prompt.git { + GIT_PS1_STATESEPARATOR=';' + GIT_PS1_SHOWDIRTYSTATE=1 + GIT_PS1_SHOWUNTRACKEDFILES= + GIT_PS1_SHOWUPSTREAM= + + GIT_PS1_HIDE_IF_PWD_IGNORED=1 + + local git_ps1="$(__git_ps1)" + git_ps1="${git_ps1##' ('}" + git_ps1="${git_ps1%')'}" + + IFS=';' read -r branch state _ <<< "$git_ps1" + + if [[ -n "$branch" ]]; then + printf ' ' + + if [[ "$state" == '*' ]]; then + prompt.bubble "$(printf '\[\e[4;32m\]%s' "$branch")" + else + prompt.bubble "$(printf '\[\e[32m\]%s' "$branch")" + fi + fi + } + + function prompt.prepare { + local err=$? + + PS1='\n' + + # change these to prompt.bubble_squared for squared user/hostname + if [[ $EUID == 0 ]]; then + PS1+="$(prompt.bubble "\\[\e[4m\\]\u@\H")" + else + PS1+="$(prompt.bubble "\u@\H")" + fi + + PS1+=" $(prompt.bubble "\\[\e[34m\\]\w")" + PS1+="$(prompt.git)" + if [[ $err != 0 ]]; then + PS1+=" $(prompt.bubble "\\[\e[31m\\]$err")" + fi + PS1+=" $(prompt.bubble "❯") " + + if [[ $err != 0 ]]; then + (exit "$err") + fi + } + + PROMPT_COMMAND='prompt.prepare' +fi + +function baller { + printf '🮲🮳⚽︎ \n' +} |