diff --git a/.context.json b/.context.json index 710924d..78598ae 100644 --- a/.context.json +++ b/.context.json @@ -179,12 +179,13 @@ } ], "config": { - "env": "PS1_STYLE=aurora|neon|forge|circuit|mono|git|hawolex; PS1_STYLE_PACK=standard|contest|holiday; PS1_CONTEST_LAYOUT=day-time-user|user-time|time-user|day-time; PS1_HOLIDAY=christmas|easter|halloween|valentine|thanksgiving|newyear", + "env": "PS1_STYLE=aurora|neon|forge|circuit|mono|git|hawolex; PS1_STYLE_PACK=standard|contest|holiday; PS1_CONTEST_LAYOUT=day-time-user|user-time|time-user|day-time; PS1_HOLIDAY=christmas|easter|halloween|valentine|thanksgiving|newyear; PS1_GIT=0|1", "config_file_keys": [ "PS1_STYLE", "PS1_STYLE_PACK", "PS1_CONTEST_LAYOUT", - "PS1_HOLIDAY" + "PS1_HOLIDAY", + "PS1_GIT" ] } }, diff --git a/dotfiles/install/install-linux-global.sh b/dotfiles/install/install-linux-global.sh index 5c8812d..a06408c 100644 --- a/dotfiles/install/install-linux-global.sh +++ b/dotfiles/install/install-linux-global.sh @@ -29,6 +29,7 @@ style_choice="aurora" style_pack="standard" contest_layout="day-time-user" holiday_choice="christmas" +git_choice="0" if [[ -t 0 ]]; then echo "Install options:" echo " 1) PS1 only" @@ -162,6 +163,14 @@ if [[ -t 0 ]]; then ""|1) style_choice="aurora" ;; *) 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 @@ -243,6 +252,9 @@ 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 } > /etc/ps1-style chmod 0644 /etc/ps1-style else diff --git a/dotfiles/install/install-macos-user.sh b/dotfiles/install/install-macos-user.sh index 22e8310..78f10c2 100644 --- a/dotfiles/install/install-macos-user.sh +++ b/dotfiles/install/install-macos-user.sh @@ -18,6 +18,7 @@ season_choice="" style_choice="aurora" contest_layout="day-time-user" holiday_choice="christmas" +git_choice="0" if [[ -t 0 ]]; then style_pack="standard" echo "PS1 mode:" @@ -138,6 +139,14 @@ if [[ -t 0 ]]; then ""|1) style_choice="aurora" ;; *) 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 @@ -164,6 +173,9 @@ 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 } > "$STYLE_FILE" chmod 0644 "$STYLE_FILE" diff --git a/dotfiles/ps1/ps1.sh b/dotfiles/ps1/ps1.sh index 7e72f52..8bafa35 100644 --- a/dotfiles/ps1/ps1.sh +++ b/dotfiles/ps1/ps1.sh @@ -94,6 +94,7 @@ _ps1_season() { # PS1_STYLE_PACK=standard|contest|holiday # PS1_CONTEST_LAYOUT=day-time-user|user-time|time-user|day-time # PS1_HOLIDAY=christmas|easter|halloween|valentine|thanksgiving|newyear +# PS1_GIT=0|1 # Also reads config from /etc/ps1-style or ~/.config/ps1/style _ps1_style_config() { local cfg="" @@ -112,6 +113,7 @@ _ps1_style_config() { PS1_STYLE_PACK) export PS1_STYLE_PACK="$v" ;; PS1_CONTEST_LAYOUT) export PS1_CONTEST_LAYOUT="$v" ;; PS1_HOLIDAY) export PS1_HOLIDAY="$v" ;; + PS1_GIT) export PS1_GIT="$v" ;; esac done < "$cfg" fi @@ -349,6 +351,7 @@ __PS1_STYLE="aurora" __PS1_STYLE_PACK="standard" __PS1_CONTEST_LAYOUT="day-time-user" __PS1_HOLIDAY="christmas" +__PS1_GIT=0 _ps1_set_prompt() { local RST="\[\e[0m\]" @@ -632,11 +635,15 @@ ${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="" + if [[ "$__PS1_GIT" == "1" ]]; then + 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} " +\n${H_FRAME}╰── ${RST}${prompt_sym} ${__PS1_SYM}${H_GIT} " ;; *) # aurora (default) @@ -668,6 +675,7 @@ _ps1_update() { __PS1_CONTEST_LAYOUT="$(_ps1_contest_layout)" __PS1_HOLIDAY="$(_ps1_holiday)" __PS1_STYLE="$(_ps1_style)" + __PS1_GIT="${PS1_GIT:-0}" __PS1_SYM="$(_ps1_symbol)" __PS1_PATH="$(_ps1_path)" if _ps1_has_nf; then __PS1_USE_NF=1; else __PS1_USE_NF=0; fi