commit 941a022719ae056105b39327651ce5dc80d6f6a1 parent 6dfbe33079e2f8c64c5daed29aa1ea3e7e3f2d59 Author: Jan Pobrislo <ccx@te2000.cz> Date: Tue, 30 Dec 2025 21:34:39 +0000 improve zsh prompt username detection, add hardstatus support Diffstat:
| M | zsh-functions/prompt_ccx_setup | | | 15 | +++++++++++++-- |
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/zsh-functions/prompt_ccx_setup b/zsh-functions/prompt_ccx_setup @@ -2,7 +2,7 @@ # vim: ft=zsh et sts=4 ts=4 sw=4 autoload -Uz ccx_prompt_hash_color -local prompt_char prompt_color_host prompt_color_jobs prompt_color_errno prompt_color_dir prompt_color_user prompt_base +local prompt_char prompt_color_host prompt_color_jobs prompt_color_errno prompt_color_dir prompt_color_user prompt_base prompt_user if [[ ${LC_ALL:-${LC_MESSAGES:-$LANG}} == *.UTF-8 ]]; then if (($UID)); then @@ -36,7 +36,18 @@ if [[ $UID -eq 0 ]]; then prompt_color_dir="%B%F{red}" fi -prompt_base="${prompt_color_user}%n${prompt_color_host}@%m%k ${prompt_color_dir}%1~" +if [[ -n $USERNAME ]]; then + prompt_user=%n +else + prompt_user=$USER +fi + +prompt_base="${prompt_color_user}${prompt_user}${prompt_color_host}@%m%k ${prompt_color_dir}%1~" PS1="%(?..${prompt_color_errno}<%?>)%(1j.${prompt_color_jobs}{%j}.)$prompt_base ${prompt_char}%b%f%k " PS2="$prompt_base %_> %b%f%k" PS3="$prompt_base ?# %b%f%k" + +# hardstatus / terminal title +if [[ $TERM == (xterm|rxvt|screen|Eterm|putty|tmux)(|-*) ]]; then + PS1=$'%{\e]2;%m%(!.#.:)%2~\e\\%}'"$PS1" +fi