aboutsummaryrefslogtreecommitdiffstats
path: root/zuwu.zsh
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-05-27 19:05:23 +0200
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-05-27 19:05:23 +0200
commit9801451e65027811baf1dbef85b1ebeca5ed4768 (patch)
tree7919f47ca8541ad49e5c724bb00f4eafd0715440 /zuwu.zsh
parent7d384c6ea9a20af2da736256b003fbd036b4c26a (diff)
downloadzuwu-9801451e65027811baf1dbef85b1ebeca5ed4768.tar.gz
zuwu-9801451e65027811baf1dbef85b1ebeca5ed4768.tar.bz2
zuwu-9801451e65027811baf1dbef85b1ebeca5ed4768.tar.lz
zuwu-9801451e65027811baf1dbef85b1ebeca5ed4768.zip

fix: __zuwu instead of _zuwu for realoadopt fn name, factor zuwu prompt into separate function

Diffstat (limited to 'zuwu.zsh')
-rwxr-xr-xzuwu.zsh107
1 files changed, 55 insertions, 52 deletions
diff --git a/zuwu.zsh b/zuwu.zsh
index e7f58ee..019aa38 100755
--- a/zuwu.zsh
+++ b/zuwu.zsh
@@ -102,7 +102,7 @@ autoload -U down-line-or-beginning-search
# Keybinds and shit
# NOTE: this provides *NO* guarantees of properly reloading things. Restart your shell for a proper reload.
-_zuwu_reloadopt() {
+__zuwu_reloadopt() {
if [[ -f "$HOME/.zshconf" ]]; then
no-op "${XDG_CONFIG_HOME:="$HOME/.config"}";
if ! [[ -d "$XDG_CONFIG_HOME" ]]; then
@@ -186,7 +186,7 @@ _zuwu_reloadopt() {
bindkey -r "^[[F"
fi
}
-_zuwu_reloadopt
+__zuwu_reloadopt
# Fix $HOME path being entirely inlined in zsh completion shit (or any other string at the beginnig thereof)
if grep "\"$HOME" "$HOME/.zshrc" >/dev/null 2>/dev/null; then
@@ -226,58 +226,61 @@ while IFS= read -r f; do
done <<< "$(_each_share_dir zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh zsh-syntax-highlighting/zsh-syntax-highlighting.zsh)"
# Cute Prompting
-if [[ "$_ZUWU_HYPERFAST-$_ZUWU_NO_PROMPT" == "-" ]]; then
- # unsure of source of function
- hsv2rgb() {
- local h=$1
- local s=$2
- local v=$3
- local s_float=$(echo "$s / 100" | bc -l)
- local v_float=$(echo "$v / 100" | bc -l)
- local r g b
- local i
- local f p q t
- i="$((h / 60))"
- f="$(echo "$h / 60 - $i" | bc -l)"
- p="$(echo "$v_float * (1 - $s_float)" | bc -l)"
- q="$(echo "$v_float * (1 - $f * $s_float)" | bc -l)"
- t="$(echo "$v_float * (1 - (1 - $f) * $s_float)" | bc -l)"
- case $i in
- 0) r=$v_float; g=$t; b=$p ;;
- 1) r=$q; g=$v_float; b=$p ;;
- 2) r=$p; g=$v_float; b=$t ;;
- 3) r=$p; g=$q; b=$v_float ;;
- 4) r=$t; g=$p; b=$v_float ;;
- 5) r=$v_float; g=$p; b=$q ;;
- esac
- r="$(printf "%.0f" $(echo "$r * 255" | bc -l))"
- g="$(printf "%.0f" $(echo "$g * 255" | bc -l))"
- b="$(printf "%.0f" $(echo "$b * 255" | bc -l))"
- echo -n "${r};${g};${b}"
- }
- local _SHORTHOST_HASH="$(sha256sum <<< "${HOST%%.*}")"
- local _SYS_RGB="${SYS_RGB:-"$(hsv2rgb "${SYS_HSV_HUE:-"$((0x${_SHORTHOST_HASH:0:2} * 360 / 256))"}" "${SYS_HSV_SATURATION:-60}" "${SYS_HSV_VALUE:-70}")"}"
- local _USER_RGB="${USER_RGB:-"$_SYS_RGB"}"
- unset -f hsv2rgb
-
- _SYS_USER_COLOUR="%F{22}$(echo -ne "\x1b[38;2;${_USER_RGB}m")"
- _SYS_SYSTEM_COLOUR="%B%F{green}$(echo -ne "\x1b[38;2;${_SYS_RGB}m")"
- if [[ "$USER" == "root" ]]; then
- _SYS_USER_COLOUR="%F{red}"
- fi
+__zuwu_updateprompt() {
+ if [[ "$_ZUWU_HYPERFAST-$_ZUWU_NO_PROMPT" == "-" ]]; then
+ # unsure of source of function
+ hsv2rgb() {
+ local h=$1
+ local s=$2
+ local v=$3
+ local s_float=$(echo "$s / 100" | bc -l)
+ local v_float=$(echo "$v / 100" | bc -l)
+ local r g b
+ local i
+ local f p q t
+ i="$((h / 60))"
+ f="$(echo "$h / 60 - $i" | bc -l)"
+ p="$(echo "$v_float * (1 - $s_float)" | bc -l)"
+ q="$(echo "$v_float * (1 - $f * $s_float)" | bc -l)"
+ t="$(echo "$v_float * (1 - (1 - $f) * $s_float)" | bc -l)"
+ case $i in
+ 0) r=$v_float; g=$t; b=$p ;;
+ 1) r=$q; g=$v_float; b=$p ;;
+ 2) r=$p; g=$v_float; b=$t ;;
+ 3) r=$p; g=$q; b=$v_float ;;
+ 4) r=$t; g=$p; b=$v_float ;;
+ 5) r=$v_float; g=$p; b=$q ;;
+ esac
+ r="$(printf "%.0f" $(echo "$r * 255" | bc -l))"
+ g="$(printf "%.0f" $(echo "$g * 255" | bc -l))"
+ b="$(printf "%.0f" $(echo "$b * 255" | bc -l))"
+ echo -n "${r};${g};${b}"
+ }
+ local _SHORTHOST_HASH="$(sha256sum <<< "${HOST%%.*}")"
+ local _SYS_RGB="${SYS_RGB:-"$(hsv2rgb "${SYS_HSV_HUE:-"$((0x${_SHORTHOST_HASH:0:2} * 360 / 256))"}" "${SYS_HSV_SATURATION:-60}" "${SYS_HSV_VALUE:-70}")"}"
+ local _USER_RGB="${USER_RGB:-"$_SYS_RGB"}"
+ unset -f hsv2rgb
+
+ _SYS_USER_COLOUR="%F{22}$(echo -ne "\x1b[38;2;${_USER_RGB}m")"
+ _SYS_SYSTEM_COLOUR="%B%F{green}$(echo -ne "\x1b[38;2;${_SYS_RGB}m")"
+ if [[ "$USER" == "root" ]]; then
+ _SYS_USER_COLOUR="%F{red}"
+ fi
- PROMPT="$(echo -n "${_SYS_USER_COLOUR}%n%f%F{7}@%f${_SYS_SYSTEM_COLOUR}%m%f%b%F{7} in %f%B%F{27}%~%f%b\n%B%F{magenta}%(?..%F{red})❯ %f%b")"
- RPROMPT="%B%F{magenta}%(?..%F{red})%?%f%b"
-elif [[ "$_ZUWU_NO_PROMPT" == "" ]]; then
- _SYS_USER_COLOUR="%F{22}"
- _SYS_SYSTEM_COLOUR="%B%F{green}"
- if [[ "$USER" == "root" ]]; then
- _SYS_USER_COLOUR="%F{red}"
- fi
+ PROMPT="$(echo -n "${_SYS_USER_COLOUR}%n%f%F{7}@%f${_SYS_SYSTEM_COLOUR}%m%f%b%F{7} in %f%B%F{27}%~%f%b\n%B%F{magenta}%(?..%F{red})❯ %f%b")"
+ RPROMPT="%B%F{magenta}%(?..%F{red})%?%f%b"
+ elif [[ "$_ZUWU_NO_PROMPT" == "" ]]; then
+ _SYS_USER_COLOUR="%F{22}"
+ _SYS_SYSTEM_COLOUR="%B%F{green}"
+ if [[ "$USER" == "root" ]]; then
+ _SYS_USER_COLOUR="%F{red}"
+ fi
- PROMPT="$(echo -n "${_SYS_USER_COLOUR}%n%f%F{7}@%f${_SYS_SYSTEM_COLOUR}%m%f%b%F{7} in %f%B%F{27}%~%f%b\n%B%F{magenta}%(?..%F{red})❯ %f%b")"
- RPROMPT="%B%F{magenta}%(?..%F{red})%?%f%b"
-fi
+ PROMPT="$(echo -n "${_SYS_USER_COLOUR}%n%f%F{7}@%f${_SYS_SYSTEM_COLOUR}%m%f%b%F{7} in %f%B%F{27}%~%f%b${_ZUWU_PROMPT_NEWLINE_SEPARATOR:="\n"}%B%F{magenta}%(?..%F{red})❯ %f%b")"
+ RPROMPT="%B%F{magenta}%(?..%F{red})%?%f%b"
+ fi
+}
+__zuwu_updateprompt
# Custom History Handling
__sethist() {