Changed color handling in prompt

Changed nice prompt
This commit is contained in:
Andrea Mistrali 2014-05-14 13:05:48 +00:00
parent bba77bdbd4
commit 593b539850
3 changed files with 62 additions and 9 deletions

View File

@ -6,12 +6,47 @@ zmodload zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
# (( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
# for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
# eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
# eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
# # (( count = $count + 1 ))
# done
# PR_NO_COLOR="%{$terminfo[sgr0]%}"
unset color
# unset color
#
typeset -Ag FX FG BG
FX=(
reset "%{%}"
bold "%{%}" no-bold "%{%}"
italic "%{%}" no-italic "%{%}"
underline "%{%}" no-underline "%{%}"
blink "%{%}" no-blink "%{%}"
reverse "%{%}" no-reverse "%{%}"
)
for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}"
done
ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
# Show all 256 colors with color number
function spectrum_ls() {
for code in {000..255}; do
# print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f"
print -P -- "$FG[$code]$code: $ZSH_SPECTRUM_TEXT $FX[reset]"
done
}
# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
for code in {000..255}; do
print -P -- "$BG[$code]$code: $ZSH_SPECTRUM_TEXT $FX[reset]"
done
}
# vim: set ts=4 sw=4 tw=0 ft=zsh :

View File

@ -0,0 +1,18 @@
function prompt_niceOld_setup {
if `fancyTerm`; then
W="::: %n at %m in %. :::"
I="%m::%."
L="%B%K{blue}%F{white}@%m::%2~ %f%k
%F{yellow}%#%f%b "
PS1="%{]2;$W%}%{]1;$I%}$L"
unset W I L
else
# We are not on xterminal
PS1="%B%K{blue}%F{white}[%l] %n@%m:%~ %f%k%F{yellow}%#%f%b "
fi
}
prompt_niceOld_setup
# vim: set ts=4 sw=4 tw=0 ft=zsh :

View File

@ -2,8 +2,8 @@ function prompt_nice_setup {
if `fancyTerm`; then
W="::: %n at %m in %. :::"
I="%m::%."
L="%B%K{blue}%F{white}@%m::%2~ %f%k
%F{yellow}%#%f%b "
L="$FX[bold]$FX[italic]$BG[111]$FG[239]@%m::%2~ $BG[000]
$FG[228]%#$FX[reset] "
PS1="%{]2;$W%}%{]1;$I%}$L"
unset W I L