updates to phudj to make the prompt progressively more annoying as you add git stashes

pull/1578/head
phreakocious 2020-09-30 19:17:39 -07:00
parent 3eb1257db0
commit ca1445e8c1
1 changed files with 15 additions and 4 deletions

View File

@ -4,7 +4,12 @@
# https://github.com/phreakocious # # https://github.com/phreakocious #
##################################### #####################################
# ★ ➤ ▶ ► ‣ ✱ ✽ ❖ ✸ ✹ ◼■ ●○•°✪ ⬤ ⚫⭕ ⧫⬧♦⬥ #
# phudj is a theme for bash-it -- https://github.com/Bash-it/bash-it
#
# ★ ➤ ▶ ► ‣ ✱ ✽ ❖ ✸ ✹ ◼■ ●○-°✪ ⧫⬧♦⬥ ⁉ ‼ ✗ ✘ ❓❔ ⁈ ※ ⁂ ⁑ ⧖ ⧗ ☆ ⚠
# ❗⚡ ✅ ❌ ✨❓ 🌀 🌈 🔥 🥓 🌞 💫 💥 💣 💡🌟⛔ ⬤ ⚫⭕ 🔴 🔵 🔶 🔷 🔸 🔹 🔺 🔻 🚫 🚀 ☄ 💢
prompt_user= prompt_user=
prompt_clean= prompt_clean=
@ -12,6 +17,7 @@
prompt_ahead= prompt_ahead=
prompt_behind= prompt_behind=
prompt_diverge= prompt_diverge=
prompt_stash=
color_user="$bold_green" color_user="$bold_green"
color_host="$green" color_host="$green"
@ -26,33 +32,38 @@
color_branch="\[$(echo_color rgb 0 255 95)\]" color_branch="\[$(echo_color rgb 0 255 95)\]"
color_success="$bold_green" color_success="$bold_green"
color_failure="$bold_red" color_failure="$bold_red"
color_stash="\[$(echo_color rgb 223 15 31)\]"
prompt_user_root= prompt_user_root=
color_user_root="$bold_red" color_user_root="$bold_red"
color_host_root="$red" color_host_root="$red"
### ###
[[ $EUID -eq 0 ]] && color_host=${color_host_root} && color_user=${color_user_root} && prompt_user="$prompt_user_root" [[ $EUID -eq 0 ]] && color_host=${color_host_root} && color_user=${color_user_root} && prompt_user="$prompt_user_root"
# seq/jot are not always available, so eval+echo+brace expansion it shall be
repeat_char() { char=$1; reps=$2; printf "${char}%.0s" $(eval echo {1..$reps}) ; }
parse_git() { parse_git() {
git_status="$(git status 2>/dev/null)" || return git_status="$(git status --show-stash 2>/dev/null)" || return
pattern_clean="working tree clean" pattern_clean="working tree clean"
pattern_ahead="Your branch is ahead of" pattern_ahead="Your branch is ahead of"
pattern_branch="^On branch ([^${IFS}]*)" pattern_branch="^On branch ([^${IFS}]*)"
pattern_behind="Your branch is behind " pattern_behind="Your branch is behind "
pattern_diverge="Your branch .* has diverged" pattern_diverge="Your branch .* has diverged"
pattern_stash="Your stash currently has ([0-9]+)"
[[ ${git_status} =~ ${pattern_clean} ]] && state="${color_clean}$prompt_clean" || state="${color_dirty}$prompt_dirty" [[ ${git_status} =~ ${pattern_clean} ]] && state="${color_clean}$prompt_clean" || state="${color_dirty}$prompt_dirty"
[[ ${git_status} =~ ${pattern_ahead} ]] && remote="${color_ahead}$prompt_ahead " [[ ${git_status} =~ ${pattern_ahead} ]] && remote="${color_ahead}$prompt_ahead "
[[ ${git_status} =~ ${pattern_behind} ]] && remote="${color_behind}$prompt_behind " [[ ${git_status} =~ ${pattern_behind} ]] && remote="${color_behind}$prompt_behind "
[[ ${git_status} =~ ${pattern_diverge} ]] && remote="${color_diverge}$prompt_diverge " [[ ${git_status} =~ ${pattern_diverge} ]] && remote="${color_diverge}$prompt_diverge "
[[ ${git_status} =~ ${pattern_branch} ]] && branch="${BASH_REMATCH[1]}" [[ ${git_status} =~ ${pattern_branch} ]] && branch="${BASH_REMATCH[1]}"
[[ ${git_status} =~ ${pattern_stash} ]] && stash="${color_stash}$(repeat_char $prompt_stash ${BASH_REMATCH[1]}) "
echo " ${color_branch}(${branch}) ${remote}${state}" echo " ${color_branch}(${branch}) ${stash}${remote}${state}"
} }
prompt_command() { prompt_command() {