1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 02:43:23 -07:00

hardcode escape codes into zsh prompt

This commit is contained in:
Connor Olding 2019-06-05 16:52:02 -07:00
parent bc1758f51e
commit ba23dc008d

View File

@ -167,15 +167,30 @@ if [[ "$TERM" = xterm* ]]; then
precmd() { print -Pn "\e]2;%M: %~\a" }
fi
# note: zsh adds a % symbol to newline-less output, so bash prompt is overkill
function {
local good='green'
[[ "$host" == neobanshee ]] && good='cyan'
[[ "$host" == spectre ]] && good='white'
[[ "$host" == wraith ]] && good='yellow'
[[ "$host" == sabotage ]] && good='magenta'
PROMPT='%{'$'\e''[10m%}%b%(?.%K{'"$good"'}.%K{red})%15F%#%f%k '
RPROMPT='%8F%h%b'
if [[ "$TERM" != xterm* ]] && [[ "$TERM" != screen* ]]; then
PROMPT="%# "
unset RPROMPT
return
fi
# zsh adds a % symbol to newline-less output, so my bash prompt is overkill
# NOTE: i've started hardcoding escapes instead of relying on zsh
# because detecting terminal features is too troublesome.
local s=$'\x1B\x5B' # start escape code
local e=m # end escape code
local reset="${s}0${e}"
local good=42 # green
local bad=41 # red
[[ "$host" == neobanshee ]] && good=46 # cyan
[[ "$host" == spectre ]] && good=47 # white
[[ "$host" == wraith ]] && good=43 # yellow
[[ "$host" == sabotage ]] && good=45 # magenta
# NOTE: i had ${s}10${e} here before, is it still necessary?
PROMPT="%{$reset${s}%(?.${good}.${bad})${e}${s}97${e}%}%#%{$reset%} "
RPROMPT="%{${s}90${e}%}%h%{$reset%}"
}
TIMEFMT=$'\e[93m%*U/%*E cpu/real (%P), %MM mem:\e[36m %J\e[0m'