Unable to set colors according to terminal support in .screenrc

I would like to have an if-else loop in .screenrc for the following codes so that it runs if my terminal supports 256 colors. Otherwise, it does not start.

attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
termcapinfo xterm-color "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"

How can you create an if-else loop in .screenrc?

+3
source share
3 answers

This should already be installed by the terminfo database file. In my case, my default terminal is xterm. It uses 8 colors, which are reflected in vi, using

: install termcap

t_Co, 8. , gnome-256color, 256 , vi t_Co 256. , .vimrc.

+2

, - , bash:

#!/bin/bash
if [ "$TERM" = "xterm-256color" ]; then
    # do stuff for 256
else
    if [ "$TERM" = "xterm" ]; then
        # do stuff for 16
    else
        # do something else entirely
    fi
fi
+1

My pseudo code attempt for .screenrc

[ -e t_Co(256) ] . ColorFile

Same thing in english

If 256 color support, then source ColorFile.
0
source

Source: https://habr.com/ru/post/1709416/


All Articles