1
0
dotfiles/.config/zsh/lib/prompt.zsh

52 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-03-21 18:25:10 +03:00
#!/bin/zsh
typeset -gA ZSHU_PM ZSHU_PS
ZSHU_PM[rst]='%b%k%u%s%f'
ZSHU_PM[crlf]=$'\n'
2024-01-16 02:55:39 +03:00
ZSHU_PS[shlvl]='%(2L.%B%F{white}|%F{cyan}%L%b%f.)'
2021-03-21 18:25:10 +03:00
ZSHU_PM[status]='▪'
ZSHU_PS[lastcmd]="%B%(?.%F{green}.%F{red})${ZSHU_PM[status]}%f%b"
ZSHU_PS[pwd_std]='%F{cyan}%B%~%f%b'
2021-05-07 17:09:11 +03:00
ZSHU_PM[cmd_user]='%F{white}$'
ZSHU_PM[cmd_root]='%F{red}#'
ZSHU_PS[cmd]="%k%B%(!.${ZSHU_PM[cmd_root]}.${ZSHU_PM[cmd_user]})${ZSHU_PM[rst]} "
2021-03-21 18:25:10 +03:00
ZSHU_PM[user]='%(!.%F{magenta}.%F{green})%n%f'
ZSHU_PM[host]="%B%(!.%F{red}.%F{blue})${ZSHU[host]}%f%b"
2021-03-21 18:25:10 +03:00
if autoload -Uz add-zsh-hook ; then
__z_pwd() {
2022-07-19 02:41:45 +03:00
local p pfx last
p=${(%):-%~}
2021-03-21 18:25:10 +03:00
[[ "$p" =~ '/.+' ]] || return
2022-07-19 02:41:45 +03:00
pfx="${p:h}"
2021-03-21 18:25:10 +03:00
pfx="${pfx%%/}"
2022-07-19 02:41:45 +03:00
last="${p:t}"
2021-03-21 18:25:10 +03:00
ZSHU_PS[pwd]="%F{cyan}${pfx}/%B${last}%f%b"
}
# ZSHU[pwd_hook]=''
__z_pwd_hook() {
2022-07-19 02:41:45 +03:00
local i
2024-01-16 02:55:39 +03:00
unset 'ZSHU_PS[pwd]'
2021-03-21 18:25:10 +03:00
for i ( ${(s: :)ZSHU[pwd_hook]} __z_pwd ) ; do
2024-01-16 02:55:39 +03:00
unset 'ZSHU_PS[pwd_extra]'
2021-03-21 18:25:10 +03:00
"$i"
(( ${+ZSHU_PS[pwd]} )) && return
done
}
add-zsh-hook precmd __z_pwd_hook
else
2024-01-16 02:55:39 +03:00
echo "shiny pwd's are disabled due to missing hook support" >&2
2021-03-21 18:25:10 +03:00
fi