From acdc2d22404c326cfb34c48b837a1b51e1b09338 Mon Sep 17 00:00:00 2001 From: Heavy Date: Sun, 3 Nov 2024 13:17:51 +0100 Subject: [PATCH] (prompt): Check if starship is installed and use it if so. --- dot_bashrc.d/executable_10.prompt.tmpl | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/dot_bashrc.d/executable_10.prompt.tmpl b/dot_bashrc.d/executable_10.prompt.tmpl index f18e4c4..6113cb8 100644 --- a/dot_bashrc.d/executable_10.prompt.tmpl +++ b/dot_bashrc.d/executable_10.prompt.tmpl @@ -52,7 +52,7 @@ function lastExitCode { function hostPrompt() { local system=$1 # echo "\[$(colf "$PROMPT_COLOR")\]░▒▓\[$(colb "$PROMPT_COLOR")\]\[$(colf 7)$(tput bold)\] $system \[$(res)$(colf "$PROMPT_COLOR")$(colb 7)\]▓▒░ \h" - echo "\[\033[1;34m\] $system \[\033[0;34m\]──\[\033[1;34m\] $myPrettyName\[\033[0;34m\]" + echo "$system \[\033[0;34m\]──\[\033[1;34m\] $myPrettyName\[\033[0;34m\]" } function statusPrompt() { local type=$1 @@ -78,7 +78,17 @@ function setPrompt() { PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}\n${USER_PROMPT}\n${DATE}" # PS1="${PROMPT} → \[$(res)\]" - PS1="\n \[\033[0;34m\]┌─ ${SYSTEM_PROMPT} ── ${DATE} \n ├─ \[\033[1;32m\]\u@\h\[\033[0;34m\] ── \[\033[1;32m\]\w\[\033[0;34m\] \n └> \[\033[1;36m\]\$ \[\033[0m\]" + local LINECOL="\[\033[0;34m\]" + local COL1="\[\033[1;32m\]" + local COL2="\[\033[1;34m\]" + local COL3="\[\033[1;36m\]" + local CLEAR="\[\033[0;\]" + + local DIV="${LINECOL}──" + local LINE1="${LINECOL}\n┌─ ${COL2}${category} ${DIV} ${COL2}${myPrettyName} ${DIV} ${DATE}" + local LINE2="${LINECOL}\n├─ ${COL1}\u@\h ${DIV} ${COL1}\w ${CLEAR}" + local LINE3="${LINECOL}\n└> \$ \[\033[0m\]" + PS1="$LINE1 $LINE2 $LINE3" } # example from http://stackoverflow.com/questions/4133904/ps1-line-with-git-current-branch-and-colors @@ -140,9 +150,17 @@ else TYPE=" $myType " fi -setPrompt "${myCategory}" "${myPrettyName}" ${myColor:-6} -# color_my_prompt +if command -v 2>&1 >/dev/null; then + echo "Found starship, using it" + STARSHIP_EXEC="$(which starship)" + eval "$($STARSHIP_EXEC init bash)" +else + echo "No starship, using custom PS1" + setPrompt "${myCategory}" "${myPrettyName}" ${myColor:-6} +fi + +# color_my_prompt # TODO: background colors... # TODO: private history file for shared accounts # TODO: vim