X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ax-zsh.git;a=blobdiff_plain;f=core%2F11_terminal%2F11_terminal.zshrc;h=3a2099e2166cdf2f9ea9202d57a8f8cdb8fcc023;hp=5e2306694fed1f45a6086fb3898cff0f72b41d6c;hb=81401f8304dc05d44e7e90ce7de1bf0e5bcd7eb8;hpb=602d2931b1cd78bbfb75a4e1fd8de7e6a8553689 diff --git a/core/11_terminal/11_terminal.zshrc b/core/11_terminal/11_terminal.zshrc index 5e23066..3a2099e 100644 --- a/core/11_terminal/11_terminal.zshrc +++ b/core/11_terminal/11_terminal.zshrc @@ -46,10 +46,10 @@ function _axzsh_is_widechar_terminal { # Test for "modern" terminal function axzsh_is_modern_terminal { + [[ "$TERM" = cygwin ]] && return 0 [[ "$TERM" = screen* ]] && return 0 [[ "$TERM" = tmux* ]] && return 0 [[ "$TERM" = xterm* ]] && return 0 - [[ "$TERM" = cygwin ]] && return 0 return 1 } @@ -135,6 +135,7 @@ alias axttyinfo="nocorrect zsh $AXZSH/bin/axttyinfo" axzsh_is_dumb_terminal && return 0 # Colors +# See , for exmaple. autoload -Uz colors colors @@ -149,36 +150,56 @@ fi # Foreground (FG) and background (BG) colors. typeset -Ag FG BG -for color in {000..255}; do - FG[$color]="%{[38;5;${color}m%}" - BG[$color]="%{[48;5;${color}m%}" -done +case "$TERM" in + *-256color) + TERM_COLORS=255 + for color in {000..$TERM_COLORS}; do + FG[$color]="%{\e[38;5;${color}m%}" + BG[$color]="%{\e[48;5;${color}m%}" + done + ;; + *) + TERM_COLORS=15 + typeset -i c + for color in {000..$TERM_COLORS}; do + c=$color + if [[ $c -ge 8 ]]; then + c=$c-8 + p="1;" + fi + FG[$color]="%{\e[${p}3${c}m%}" + BG[$color]="%{\e[${p}4${c}m%}" + done + unset c p +esac +export TERM_COLORS # Text effects (FX) +# See , for example. typeset -Ag FX FX=( - reset "%{%}" - bold "%{%}" no-bold "%{%}" - italic "%{%}" no-italic "%{%}" - underline "%{%}" no-underline "%{%}" - blink "%{%}" no-blink "%{%}" - reverse "%{%}" no-reverse "%{%}" + reset "%{\e[0m%}" + bold "%{\e[1m%}" no-bold "%{\e[22m%}" + italic "%{\e[3m%}" no-italic "%{\e[23m%}" + underline "%{\e[4m%}" no-underline "%{\e[24m%}" + blink "%{\e[5m%}" no-blink "%{\e[25m%}" + reverse "%{\e[7m%}" no-reverse "%{\e[27m%}" ) ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-The quick brown fox jumps over the lazy dog} # Show all 256 foreground colors with color number function spectrum_ls() { - for code in {000..255}; do - print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" + for code in {000..$TERM_COLORS}; do + print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT$FX[reset]" done } # Show all 256 background colors with color number function spectrum_bls() { - for code in {000..255}; do - print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" + for code in {000..$TERM_COLORS}; do + print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT$FX[reset]" done }