Qualcuno potrebbe spiegarlo? Sto usando gnome-terminal
. Innanzitutto, alcune informazioni:
# echo $TERM
xterm
# infocmp xterm
Reconstructed via infocmp from file: /lib/terminfo/x/xterm
colors#8, cols#80, it#8, lines#24, pairs#64
# tput colors
8
Ho scritto un semplice script per creare codici per un set esteso di colori:
# Output file (current directory) and text.
OFILE='xterm256_colors_test.sh'
OFILE_COLORS='terminal_256_colors'
OTEXT='Sed ut perspiciatis unde omnis iste natus error sit voluptatem...'
# Clearing the contents from previous runs.
if [ -e $OFILE ] || [ -e $OFILE_COLORS ]
then
> $OFILE
> $OFILE_COLORS
fi
# Bang!
echo -e '#!/bin/bash\n' | tee --append $OFILE $OFILE_COLORS &> /dev/null
echo -e "\necho -e \"" | tee --append $OFILE &> /dev/null
# \x1b is a control character changing behaviour of the shell.
# It is also the <Ctrl+V><Esc> sequence.
for i in {016..255}; do
echo -e "\x1b[38;5;${i}m $OTEXT $i \x1b[0m" >> $OFILE
echo -e "color${i}=\"\[\033[38;5;${i}m\]\"" >> $OFILE_COLORS
done
# End of echo.
echo '"' | tee --append $OFILE &> /dev/null
# The file should be executable.
chmod +x $OFILE
Nonostante l' xterm
emulatore di terminale di base quando eseguo lo script generato posso vedere tutti i 240 colori. Perché? Ho pensato di passare $TERM
al xterm-256color
primo.