aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorCaroline Larimore <caroline@larimo.re>2024-08-15 16:27:30 -0700
committerCaroline Larimore <caroline@larimo.re>2024-08-15 16:27:30 -0700
commit515c2306c611b6ad733f2a99a1dbd7d27cc36b24 (patch)
tree39f198a4b7c30f6644c51b68d49a1a2535b245bd /core
parent16e6f5c2c93f36fa9d052958ca5e4355afc0e3af (diff)
core: add prompt support for more terminals
Diffstat (limited to 'core')
-rw-r--r--core/bash/prompt.sh117
1 files changed, 64 insertions, 53 deletions
diff --git a/core/bash/prompt.sh b/core/bash/prompt.sh
index b43905d..bae2237 100644
--- a/core/bash/prompt.sh
+++ b/core/bash/prompt.sh
@@ -1,71 +1,82 @@
-if [[ "$TERM" == "xterm-kitty" ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")/git-prompt.sh"
+source "$(dirname "${BASH_SOURCE[0]}")/git-prompt.sh"
+
+PROMPT_CHAR='❯'
+if [[ "$TERM" == "xterm-kitty" ]]; then
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\]' "$@";
}
+elif [[ "$TERM" == "xterm-256color" ]]; then
+ function prompt.bubble {
+ printf '\[\e[38;5;237m\](\[\e[0m\]%s\[\e[0m\e[38;5;237m\])\[\e[0m\]' "$@";
+ }
+else
+ PROMPT_CHAR='>'
+ function prompt.bubble {
+ printf '\[\e[2;39m\](\[\e[0m\]%s\[\e[0m\e[2;39m\])\[\e[0m\]' "$@";
+ }
+fi
- function prompt.git {
- GIT_PS1_STATESEPARATOR=';'
- GIT_PS1_SHOWDIRTYSTATE=1
- GIT_PS1_SHOWUNTRACKEDFILES=
- GIT_PS1_SHOWUPSTREAM=
+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%')'}"
+ 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"
+ IFS=';' read -r branch state _ <<< "$git_ps1"
- if [[ -n "$branch" ]]; then
- printf ' '
+ 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
+ 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'
-
- local subshell=''
- if [[ -n "$IN_NIX_SHELL" ]]; then
- subshell="\\[\e[33m\\]nix"
- fi
- if [[ $SHLVL != 1 && ! ($SHLVL == 2 && -n "$IN_NIX_SHELL") ]]; then
- if [[ -n "$subshell" ]]; then subshell+="\\[\e[39m\\] "; fi
- subshell+="\\[\e[2;37m\\]$SHLVL"
- fi
- if [[ -n "$subshell" ]]; then
- PS1+="$(prompt.bubble "$subshell") "
- fi
+function prompt.prepare {
+ local err=$?
+ PS1='\n'
+
+ local subshell=''
+ if [[ -n "$IN_NIX_SHELL" ]]; then
+ subshell="\\[\e[33m\\]nix"
+ fi
+ if [[ $SHLVL != 1 && ! ($SHLVL == 2 && -n "$IN_NIX_SHELL") ]]; then
+ if [[ -n "$subshell" ]]; then subshell+="\\[\e[39m\\] "; fi
+ subshell+="\\[\e[2;37m\\]$SHLVL"
+ fi
+ if [[ -n "$subshell" ]]; then
+ PS1+="$(prompt.bubble "$subshell") "
+ fi
- if [[ $EUID == 0 ]]; then
- PS1+="$(prompt.bubble "\\[\e[4m\\]\u@\H")"
- else
- PS1+="$(prompt.bubble "\u@\H")"
- fi
+ 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 "❯") "
+ PS1+=" $(prompt.bubble "\\[\e[34m\\]\w")"
+ PS1+="$(prompt.git)"
+ if [[ $err != 0 ]]; then
+ PS1+=" $(prompt.bubble "\\[\e[31m\\]$err")"
+ fi
+ PS1+=" $(prompt.bubble "$PROMPT_CHAR") "
- if [[ $err != 0 ]]; then
- (exit "$err")
- fi
- }
+ if [[ $err != 0 ]]; then
+ (exit "$err")
+ fi
+}
- PROMPT_COMMAND='prompt.prepare'
-fi
+PROMPT_COMMAND='prompt.prepare'
function baller {
printf '🮲🮳⚽︎ \n'