Add git capsule toggle across themes

This commit is contained in:
2026-01-24 14:30:34 +00:00
parent c039075927
commit d7c08d5a4c
4 changed files with 49 additions and 36 deletions

View File

@@ -43,7 +43,8 @@
"Season pick (if single season)", "Season pick (if single season)",
"Contest layout selection (if contest/holidays)", "Contest layout selection (if contest/holidays)",
"Style preset selection (if contest)", "Style preset selection (if contest)",
"Holiday selection (if holidays)" "Holiday selection (if holidays)",
"Enable git capsule for all themes (if PS1 selected)"
], ],
"season_config_file": "/etc/ps1-season", "season_config_file": "/etc/ps1-season",
"style_config_file": "/etc/ps1-style", "style_config_file": "/etc/ps1-style",
@@ -64,7 +65,8 @@
"Season pick (if single season)", "Season pick (if single season)",
"Contest layout selection (if contest/holidays)", "Contest layout selection (if contest/holidays)",
"Style preset selection (if contest)", "Style preset selection (if contest)",
"Holiday selection (if holidays)" "Holiday selection (if holidays)",
"Enable git capsule for all themes"
], ],
"season_config_file": "~/.config/ps1/season", "season_config_file": "~/.config/ps1/season",
"style_config_file": "~/.config/ps1/style" "style_config_file": "~/.config/ps1/style"

View File

@@ -164,15 +164,17 @@ if [[ -t 0 ]]; then
*) echo "Invalid choice, using aurora."; style_choice="aurora" ;; *) echo "Invalid choice, using aurora."; style_choice="aurora" ;;
esac esac
if [[ "$style_choice" == "hawolex" ]]; then else
read -r -p "Enable git capsule? [y/N]: " git_pick style_choice="aurora"
fi
read -r -p "Enable git capsule for all themes? [y/N]: " git_pick
case "${git_pick}" in case "${git_pick}" in
y|Y) git_choice="1" ;; y|Y) git_choice="1" ;;
*) git_choice="0" ;; *) git_choice="0" ;;
esac esac
fi if [[ "$style_choice" == "git" ]]; then
else git_choice="1"
style_choice="aurora"
fi fi
fi fi
fi fi
@@ -252,9 +254,7 @@ if [[ "$install_ps1" -eq 1 ]]; then
if [[ "$style_pack" == "holiday" ]]; then if [[ "$style_pack" == "holiday" ]]; then
printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}" printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}"
fi fi
if [[ "$style_choice" == "hawolex" ]]; then
printf 'PS1_GIT=%s\n' "$git_choice" printf 'PS1_GIT=%s\n' "$git_choice"
fi
} > /etc/ps1-style } > /etc/ps1-style
chmod 0644 /etc/ps1-style chmod 0644 /etc/ps1-style
else else

View File

@@ -140,15 +140,17 @@ if [[ -t 0 ]]; then
*) echo "Invalid choice, using aurora."; style_choice="aurora" ;; *) echo "Invalid choice, using aurora."; style_choice="aurora" ;;
esac esac
if [[ "$style_choice" == "hawolex" ]]; then else
read -r -p "Enable git capsule? [y/N]: " git_pick style_choice="aurora"
fi
read -r -p "Enable git capsule for all themes? [y/N]: " git_pick
case "${git_pick}" in case "${git_pick}" in
y|Y) git_choice="1" ;; y|Y) git_choice="1" ;;
*) git_choice="0" ;; *) git_choice="0" ;;
esac esac
fi if [[ "$style_choice" == "git" ]]; then
else git_choice="1"
style_choice="aurora"
fi fi
fi fi
@@ -173,9 +175,7 @@ chmod 0644 "$SEASON_FILE"
if [[ "$style_pack" == "holiday" ]]; then if [[ "$style_pack" == "holiday" ]]; then
printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}" printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}"
fi fi
if [[ "$style_choice" == "hawolex" ]]; then
printf 'PS1_GIT=%s\n' "$git_choice" printf 'PS1_GIT=%s\n' "$git_choice"
fi
} > "$STYLE_FILE" } > "$STYLE_FILE"
chmod 0644 "$STYLE_FILE" chmod 0644 "$STYLE_FILE"

View File

@@ -152,6 +152,21 @@ _ps1_git_enabled() {
esac esac
} }
_ps1_git_line_tail() {
if [[ "$(_ps1_git_enabled)" == "1" ]]; then
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
local info
info="$(__git_capsule)"
if [[ -n "$info" ]]; then
printf "%s " "$info"
return
fi
fi
printf " "
}
# ---- Load Git prompt helper (best effort) ---- # ---- Load Git prompt helper (best effort) ----
__try_source_git_prompt() { __try_source_git_prompt() {
local candidates=( local candidates=(
@@ -522,6 +537,10 @@ _ps1_set_prompt() {
fi fi
local style="${__PS1_STYLE:-aurora}" local style="${__PS1_STYLE:-aurora}"
local git_tail=""
if [[ "$style" != "git" ]]; then
git_tail="$(_ps1_git_line_tail)"
fi
local L1="\\d \\A \\u" local L1="\\d \\A \\u"
local L_HOST="@\\h" local L_HOST="@\\h"
local PREFIX="" local PREFIX=""
@@ -569,7 +588,7 @@ _ps1_set_prompt() {
${PREFIX}${N_FRAME}╭─${RST}\ ${PREFIX}${N_FRAME}╭─${RST}\
${N_LEFT_FG}${N_LEFT}${RST}${N1_BG}${N1_FG} ${BOLD}\\u${NOBOLD} \\d \\A ${RST}${N1_BG}${N2_BG}${N2_FG}${N_SEP}${RST}\ ${N_LEFT_FG}${N_LEFT}${RST}${N1_BG}${N1_FG} ${BOLD}\\u${NOBOLD} \\d \\A ${RST}${N1_BG}${N2_BG}${N2_FG}${N_SEP}${RST}\
${N2_BG}${N2_FG} ${HOST_PART}${PATH_SEP}${N_PATH_FG}${PATH_PART}${END_PAD}${RST}${N_RIGHT_FG}${N_RIGHT}${RST}\ ${N2_BG}${N2_FG} ${HOST_PART}${PATH_SEP}${N_PATH_FG}${PATH_PART}${END_PAD}${RST}${N_RIGHT_FG}${N_RIGHT}${RST}\
\n${N_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} " \n${N_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
forge) forge)
local F1_BG_CODE=94 local F1_BG_CODE=94
@@ -596,7 +615,7 @@ ${N2_BG}${N2_FG} ${HOST_PART}${PATH_SEP}${N_PATH_FG}${PATH_PART}${END_PAD}${RST}
${PREFIX}${F_FRAME}╭─${RST}\ ${PREFIX}${F_FRAME}╭─${RST}\
${F_LEFT_FG}${F_LEFT}${RST}${F1_BG}${F1_FG} ${BOLD}${L1}${NOBOLD} ${RST}${F1_BG}${F2_BG}${F2_FG}${F_SEP}${RST}\ ${F_LEFT_FG}${F_LEFT}${RST}${F1_BG}${F1_FG} ${BOLD}${L1}${NOBOLD} ${RST}${F1_BG}${F2_BG}${F2_FG}${F_SEP}${RST}\
${F2_BG}${F2_FG} ${HOST_PART}${PATH_SEP}${F_PATH_FG}${PATH_PART}${END_PAD}${RST}${F_RIGHT_FG}${F_RIGHT}${RST}\ ${F2_BG}${F2_FG} ${HOST_PART}${PATH_SEP}${F_PATH_FG}${PATH_PART}${END_PAD}${RST}${F_RIGHT_FG}${F_RIGHT}${RST}\
\n${F_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} " \n${F_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
circuit) circuit)
local C_FG="\[\e[38;5;46m\]" local C_FG="\[\e[38;5;46m\]"
@@ -605,14 +624,14 @@ ${F2_BG}${F2_FG} ${HOST_PART}${PATH_SEP}${F_PATH_FG}${PATH_PART}${END_PAD}${RST}
PS1="\ PS1="\
${PREFIX}${C_DIM}┏━${RST}${C_FG}[${BOLD}\\u${NOBOLD} ${RST}${C_FG}\\A${RST}${C_DIM}]${RST}\ ${PREFIX}${C_DIM}┏━${RST}${C_FG}[${BOLD}\\u${NOBOLD} ${RST}${C_FG}\\A${RST}${C_DIM}]${RST}\
${C_DIM}${RST}${C_FG}${HOST_PART}${RST}${PATH_SEP}${C_PATH}${PATH_PART}${RST}\ ${C_DIM}${RST}${C_FG}${HOST_PART}${RST}${PATH_SEP}${C_PATH}${PATH_PART}${RST}\
\n${C_DIM}┗━${RST}${prompt_sym} ${__PS1_SYM} " \n${C_DIM}┗━${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
mono) mono)
local M_FG="\[\e[38;5;250m\]" local M_FG="\[\e[38;5;250m\]"
local M_DIM="\[\e[38;5;240m\]" local M_DIM="\[\e[38;5;240m\]"
PS1="\ PS1="\
${PREFIX}${M_FG}${L1}${M_DIM}${HOST_PART}${PATH_SEP}${M_FG}${PATH_PART}${RST}\ ${PREFIX}${M_FG}${L1}${M_DIM}${HOST_PART}${PATH_SEP}${M_FG}${PATH_PART}${RST}\
\n${M_DIM}└─${RST}${prompt_sym} ${__PS1_SYM} " \n${M_DIM}└─${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
git) git)
export GIT_PS1_SHOWDIRTYSTATE=1 export GIT_PS1_SHOWDIRTYSTATE=1
@@ -649,19 +668,11 @@ ${G_Z2_BG}${G_Z2_FG} ${HOST_PART}${PATH_SEP}${G_PATH_FG}${PATH_PART}${G_END_PAD}
local H_SEP="" local H_SEP=""
local H_LEFT_FG="\[\e[38;5;54m\]" local H_LEFT_FG="\[\e[38;5;54m\]"
local H_RIGHT_FG="\[\e[38;5;31m\]" local H_RIGHT_FG="\[\e[38;5;31m\]"
local H_GIT=""
local H_GIT_ON="$(_ps1_git_enabled)"
if [[ "$H_GIT_ON" == "1" ]]; then
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
H_GIT="$(__git_capsule)"
fi
PS1="\ PS1="\
${PREFIX}${H_FRAME}╭─${RST}\ ${PREFIX}${H_FRAME}╭─${RST}\
${H_LEFT_FG}${H_LEFT}${RST}${H_Z1_BG}${H_Z1_FG} ${L1} ${RST}${H_Z1_BG}${H_Z2_BG}${H_Z2_FG}${H_SEP}${RST}\ ${H_LEFT_FG}${H_LEFT}${RST}${H_Z1_BG}${H_Z1_FG} ${L1} ${RST}${H_Z1_BG}${H_Z2_BG}${H_Z2_FG}${H_SEP}${RST}\
${H_Z2_BG}${H_Z2_FG} ${HOST_PART}${PATH_SEP}${H_PATH_FG}${PATH_PART}${END_PAD}${RST}${H_RIGHT_FG}${H_RIGHT}${RST}\ ${H_Z2_BG}${H_Z2_FG} ${HOST_PART}${PATH_SEP}${H_PATH_FG}${PATH_PART}${END_PAD}${RST}${H_RIGHT_FG}${H_RIGHT}${RST}\
\n${H_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} ${H_GIT} " \n${H_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
*) *)
# aurora (default) # aurora (default)
@@ -681,7 +692,7 @@ ${H_Z2_BG}${H_Z2_FG} ${HOST_PART}${PATH_SEP}${H_PATH_FG}${PATH_PART}${END_PAD}${
${PREFIX}${FRAME}╭─${RST}\ ${PREFIX}${FRAME}╭─${RST}\
${A_LEFT_FG}${A_LEFT}${RST}${Z1_BG}${Z1_FG} ${L1} ${RST}${Z1_BG}${Z2_BG}${Z2_FG}${A_SEP}${RST}\ ${A_LEFT_FG}${A_LEFT}${RST}${Z1_BG}${Z1_FG} ${L1} ${RST}${Z1_BG}${Z2_BG}${Z2_FG}${A_SEP}${RST}\
${Z2_BG}${Z2_FG} ${HOST_PART}${PATH_SEP}${PATH_FG}${PATH_PART}${END_PAD}${RST}${A_RIGHT_FG}${A_RIGHT}${RST}\ ${Z2_BG}${Z2_FG} ${HOST_PART}${PATH_SEP}${PATH_FG}${PATH_PART}${END_PAD}${RST}${A_RIGHT_FG}${A_RIGHT}${RST}\
\n${FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} " \n${FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
;; ;;
esac esac
} }