mirror of
https://github.com/notwa/rc
synced 2025-02-05 07:43:22 -08:00
hardcode escape codes into zsh prompt
This commit is contained in:
parent
bc1758f51e
commit
ba23dc008d
1 changed files with 23 additions and 8 deletions
31
home/zshrc
31
home/zshrc
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue