From 867b49fc00d54fac0a0dd875bfbdd161083d860f Mon Sep 17 00:00:00 2001 From: memdmp Date: Wed, 15 Jan 2025 11:42:57 +0100 Subject: feat: env variables for loading zuwu faster All of these are booleans, where *only* an empty value is false: - _ZUWU_HYPERFAST: Attempt to load shell as fast as possible without too many compromises - _ZUWU_NO_STARSHIP: Skip starship detection - _ZUWU_NO_PROMPT: Don't set a prompt Additionally, we create a .zshenv for the user if it doesnt exist --- zuwu.zsh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'zuwu.zsh') diff --git a/zuwu.zsh b/zuwu.zsh index ea67cc8..0161be7 100755 --- a/zuwu.zsh +++ b/zuwu.zsh @@ -15,8 +15,12 @@ export _ZUWU_INSTALLED=1; if [[ "$_ZUWU_DEBUG" == "1" ]]; then set -ax; fi # Completion Handling +eval_append() { + <<<"$2" >> "$1" + eval "$2" +} if ! grep '# The following lines were added by compinstall' ~/.zshrc >/dev/null 2>/dev/null && ! grep 'compinit' ~/.zshrc >/dev/null 2>/dev/null; then - <> ~/.zshrc + eval_append ~/.zshrc "$(</dev/null 2>/dev/null; then - <>~/.zshrc + eval_append ~/.zshrc "$(< +# + +# +# This file was generated by zuwu. You can modify it as you please. +# Changes will only be reverted if the file is removed. +# We recommend, for the sake of readability, removing this generated comment when changing this file for the first time. +# + +# Remove the following line if you do not want zuwu's environment. +for d in /usr/share/zsh/plugins/zuwu /usr/local/share/zsh/plugins/zuwu "\$HOME/.local/share/zsh/plugins/zuwu"; do + if [[ -f "\$d/env.zsh" ]]; then + source "\$d/env.zsh" + break + fi +done + +# Put your custom environment variables below this line. +EOF +)"; fi # - @@ -180,10 +218,10 @@ while IFS= read -r f; do done <<< "$(_each_share_dir zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh)" # Cute Prompting -if [[ -f ~/.config/starship.toml ]]; then +if [[ "$_ZUWU_NO_STARSHIP-$_ZUWU_NO_PROMPT" == "-" ]] && [[ -f ~/.config/starship.toml ]] && type "starship" >/dev/null; then eval "$(starship init zsh)" -else - # unsure of source of function, +elif [[ "$_ZUWU_HYPERFAST-$_ZUWU_NO_PROMPT" == "-" ]]; then + # unsure of source of function hsv2rgb() { local h=$1 local s=$2 @@ -217,7 +255,16 @@ else _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 [[ "$(whoami)" == "root" ]]; then + 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 -- cgit v1.2.3