12

Putty has this "allow terminal use xterm 256 colour mode" that I'd like to use, but I don't know how. I've been using a color.sh script to output echo statements and commands with colors, and I want to do something like that with xterm colors.

#!/bin/bash ## Specify color to write in using arguments function --help { cat << EOF ERROR: $0 requires a color argument. USAGE: Changes the color of the text piped into it. These color arguments are availabe: ARGUMENT SHORTCUT white ------ w red ------ r green ------ g yellow ------ y blue ------ b violet ------ v teal ------ t bold ------ bb The "bold" argument will modify any color. Use a max of 2 arguments (one color and bold). EOF } function bold { # make the color bold BOLD=1\; } function white { COLOR=1 } function red { COLOR=31 } function green { COLOR=32 } function yellow { COLOR=33 } function blue { COLOR=34 } function violet { COLOR=35 } function teal { COLOR=36 } ## shortcuts function bb { bold } function w { white } function r { red } function g { green } function y { yellow } function b { blue } function v { violet } function t { teal } function o { red bold } ## Execution if [ "$#" = 0 ] then --help fi while (($#)); do $1 shift done echo -n "["$BOLD""$COLOR"m" cat echo -n "[0m" 
1
  • Did you try the "use system colors" option ? Or maybe you can take a look to "terminal compatibility" Commented Sep 7, 2011 at 18:25

3 Answers 3

22

For me, I had to go into settings and set the terminal type. Settings -> Connection > Data > Terminal-type change to xterm-256color.

3
  • 1
    What @directedition said is nearly correct but setting the TERM value to putty-256color is more accurate if that is supported. Settings -> Connection > Data > Terminal-type change to putty-256color. I don't have comment permission. See this answer for more info: superuser.com/a/1069018/1030245 Commented Aug 7, 2019 at 18:43
  • xterm-256color worked good for me, while putty-256color caused errors when using arrows or less tool. Connecting to Ubuntu 19 Commented Apr 8, 2020 at 9:00
  • 1
    This answer seems to be better suited for 2020's Ubuntu Installations and Windows Putty users Commented Aug 24, 2020 at 9:06
13

According to the PuTTY user manual this should be enabled by default:

If you have an application which is supposed to use 256-colour mode and it isn't working, you may find you need to tell your server that your terminal supports 256 colours. On Unix, you do this by ensuring that the setting of TERM describes a 256-colour-capable terminal. You can check this using a command such as infocmp:
$ infocmp | grep colors colors#256, cols#80, it#8, lines#24, pairs#256,
If you do not see colors#256 in the output, you may need to change your terminal setting. On modern Linux machines, you could try xterm-256color.

If you are looking to use 256 colours in a specific application, like Vim or Emacs, there are separate guides for how to achieve that:

2
  • 1
    A simpler way to get the number of available colors for the current $TERM value is tput colors. Commented Sep 8, 2011 at 11:46
  • 6
    You can also try to configure Putty's terminal type (Connection->Data->Terminal-type string) to putty-256color which may be recognized by your system. Commented May 13, 2016 at 21:00
3

Click on the System menu at the upper left corner of the PuTTY window.

Select Change Settings > Window > Colours. In the box that says "Select a colour to adjust", choose ANSI Blue and click the Modify Button. Slide the black arrow on the right up until you see a lighter shade of blue that you like. Click OK. Perform the same steps for ANSI Blue Bold so you can have a perceptible difference between the two. When you're finished, click Apply.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.