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

101 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2021-03-21 18:25:10 +03:00
#!/bin/zsh
2024-01-16 02:55:39 +03:00
typeset -gA ZSHU_PS1
2021-03-21 18:25:10 +03:00
## three-line prompt
function {
local -a line
line+="${ZSHU_PM[rst]}"
line+="%B%F{black}┌[%b"
line+="%F{yellow}%D{%y.%m.%d} %B%D{%H:%M:%S}%f%b"
line+="%B%F{black}|%b"
2021-05-07 17:11:02 +03:00
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
2021-03-21 18:25:10 +03:00
line+="${ZSHU_PM[user]}%F{white}@${ZSHU_PM[host]}"
line+='${ZSHU_PS[elapsed]}'
line+="${ZSHU_PM[rst]}"
line+="${ZSHU_PM[crlf]}"
line+="%B%F{black}┝%f%b "
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
line+='${ZSHU_PS[pwd_extra]}'
line+="${ZSHU_PM[rst]}"
line+="${ZSHU_PM[crlf]}"
line+="%B%F{black}└[%f%b"
line+="${ZSHU_PS[lastcmd]}"
2024-01-16 02:55:39 +03:00
line+='${ZSHU_PS[shlvl]}'
2021-03-21 18:25:10 +03:00
line+="%B%F{black}|%b%f"
line+="${ZSHU_PS[cmd]}"
2024-01-16 02:55:39 +03:00
ZSHU_PS1[3L]="${(j::)line}"
2021-03-21 18:25:10 +03:00
}
## two-line prompt
function {
local -a line
line+="${ZSHU_PM[rst]}"
line+="%B%F{black}┌[%b"
2021-05-07 17:11:02 +03:00
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
2021-03-21 18:25:10 +03:00
line+="${ZSHU_PM[user]}%F{white}@${ZSHU_PM[host]}"
line+="%B%F{black}|%b"
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
line+='${ZSHU_PS[pwd_extra]}'
line+='${ZSHU_PS[elapsed]}'
line+="${ZSHU_PM[rst]}"
line+="${ZSHU_PM[crlf]}"
line+="%B%F{black}└[%f%b"
line+="${ZSHU_PS[lastcmd]}"
2024-01-16 02:55:39 +03:00
line+='${ZSHU_PS[shlvl]}'
2021-03-21 18:25:10 +03:00
line+="%B%F{black}|%b%f"
line+="${ZSHU_PS[cmd]}"
2024-01-16 02:55:39 +03:00
ZSHU_PS1[2L]="${(j::)line}"
2021-03-21 18:25:10 +03:00
}
## one-line prompt
function {
local -a line
line+="${ZSHU_PM[rst]}"
line+="${ZSHU_PS[lastcmd]}"
2024-01-16 02:55:39 +03:00
line+='${ZSHU_PS[shlvl]}'
2021-03-21 18:25:10 +03:00
line+="%B%F{black}|%b"
line+="${ZSHU_PM[user]}"
line+="%B%F{black}|%b"
2021-05-07 17:11:02 +03:00
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
2021-03-21 18:25:10 +03:00
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
line+='${ZSHU_PS[pwd_extra]}'
line+='${ZSHU_PS[elapsed]}'
line+="%B%F{black}|%b"
line+="${ZSHU_PS[cmd]}"
2024-01-16 02:55:39 +03:00
ZSHU_PS1[1L]="${(j::)line}"
2021-03-21 18:25:10 +03:00
}
2024-02-28 23:22:33 +03:00
z-ps1() {
2024-01-16 02:55:39 +03:00
[ -n "$1" ] || {
echo "${ZSHU_PS[ps1]}"
return
}
local k
for k ( "$1" "${1}L" ) ; do
(( ${+ZSHU_PS1[$k]} )) || continue
ZSHU_PS[ps1]=$k
PS1=${ZSHU_PS1[$k]}
return
done
return 1
}
2024-02-28 23:22:33 +03:00
z-ps1 3
[ "${ZSHU_RUN[nested]}" = 1 ] && z-ps1 2
[ "${ZSHU_RUN[nested1L]}" = 1 ] && z-ps1 1