Add git capsule toggle across themes
This commit is contained in:
@@ -164,16 +164,18 @@ if [[ -t 0 ]]; then
|
||||
*) echo "Invalid choice, using aurora."; style_choice="aurora" ;;
|
||||
esac
|
||||
|
||||
if [[ "$style_choice" == "hawolex" ]]; then
|
||||
read -r -p "Enable git capsule? [y/N]: " git_pick
|
||||
case "${git_pick}" in
|
||||
y|Y) git_choice="1" ;;
|
||||
*) git_choice="0" ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
style_choice="aurora"
|
||||
fi
|
||||
|
||||
read -r -p "Enable git capsule for all themes? [y/N]: " git_pick
|
||||
case "${git_pick}" in
|
||||
y|Y) git_choice="1" ;;
|
||||
*) git_choice="0" ;;
|
||||
esac
|
||||
if [[ "$style_choice" == "git" ]]; then
|
||||
git_choice="1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -252,9 +254,7 @@ if [[ "$install_ps1" -eq 1 ]]; then
|
||||
if [[ "$style_pack" == "holiday" ]]; then
|
||||
printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}"
|
||||
fi
|
||||
if [[ "$style_choice" == "hawolex" ]]; then
|
||||
printf 'PS1_GIT=%s\n' "$git_choice"
|
||||
fi
|
||||
printf 'PS1_GIT=%s\n' "$git_choice"
|
||||
} > /etc/ps1-style
|
||||
chmod 0644 /etc/ps1-style
|
||||
else
|
||||
|
||||
@@ -140,16 +140,18 @@ if [[ -t 0 ]]; then
|
||||
*) echo "Invalid choice, using aurora."; style_choice="aurora" ;;
|
||||
esac
|
||||
|
||||
if [[ "$style_choice" == "hawolex" ]]; then
|
||||
read -r -p "Enable git capsule? [y/N]: " git_pick
|
||||
case "${git_pick}" in
|
||||
y|Y) git_choice="1" ;;
|
||||
*) git_choice="0" ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
style_choice="aurora"
|
||||
fi
|
||||
|
||||
read -r -p "Enable git capsule for all themes? [y/N]: " git_pick
|
||||
case "${git_pick}" in
|
||||
y|Y) git_choice="1" ;;
|
||||
*) git_choice="0" ;;
|
||||
esac
|
||||
if [[ "$style_choice" == "git" ]]; then
|
||||
git_choice="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$DST_DIR"
|
||||
@@ -173,9 +175,7 @@ chmod 0644 "$SEASON_FILE"
|
||||
if [[ "$style_pack" == "holiday" ]]; then
|
||||
printf 'PS1_HOLIDAY=%s\n' "${holiday_choice:-christmas}"
|
||||
fi
|
||||
if [[ "$style_choice" == "hawolex" ]]; then
|
||||
printf 'PS1_GIT=%s\n' "$git_choice"
|
||||
fi
|
||||
printf 'PS1_GIT=%s\n' "$git_choice"
|
||||
} > "$STYLE_FILE"
|
||||
chmod 0644 "$STYLE_FILE"
|
||||
|
||||
|
||||
@@ -152,6 +152,21 @@ _ps1_git_enabled() {
|
||||
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) ----
|
||||
__try_source_git_prompt() {
|
||||
local candidates=(
|
||||
@@ -522,6 +537,10 @@ _ps1_set_prompt() {
|
||||
fi
|
||||
|
||||
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 L_HOST="@\\h"
|
||||
local PREFIX=""
|
||||
@@ -569,7 +588,7 @@ _ps1_set_prompt() {
|
||||
${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}\
|
||||
${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)
|
||||
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}\
|
||||
${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}\
|
||||
\n${F_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} "
|
||||
\n${F_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
|
||||
;;
|
||||
circuit)
|
||||
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="\
|
||||
${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}\
|
||||
\n${C_DIM}┗━${RST}${prompt_sym} ${__PS1_SYM} "
|
||||
\n${C_DIM}┗━${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
|
||||
;;
|
||||
mono)
|
||||
local M_FG="\[\e[38;5;250m\]"
|
||||
local M_DIM="\[\e[38;5;240m\]"
|
||||
PS1="\
|
||||
${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)
|
||||
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_LEFT_FG="\[\e[38;5;54m\]"
|
||||
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="\
|
||||
${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_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)
|
||||
@@ -681,7 +692,7 @@ ${H_Z2_BG}${H_Z2_FG} ${HOST_PART}${PATH_SEP}${H_PATH_FG}${PATH_PART}${END_PAD}${
|
||||
${PREFIX}${FRAME}╭─${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}\
|
||||
\n${FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM} "
|
||||
\n${FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${git_tail}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user