Skip to main content
104 votes

How to color diff output?

diff --color option was added to GNU diffutils 3.4 (2016-08-08) This is the default diff implementation on most distros, which will soon be getting it. Ubuntu 18.04 has diffutils 3.6 and therefore has ...
Ciro Santilli OurBigBook.com's user avatar
80 votes
Accepted

Print true color (24-bit) test pattern

The following script will produce a test pattern like: You can optionally call it as: width=1000 truecolor-test and it will print a pattern of width columns. #!/bin/bash # Based on: https://gist....
Tom Hale's user avatar
  • 31.2k
68 votes
Accepted

Inconsistent color output from `ls` command

It looks as if your prompt-string ($PS1) is setting the bold attribute on characters to make the colors nicer, and not unsetting it. The output from ls doesn't know about this, and does unset bold. ...
Thomas Dickey's user avatar
55 votes

Why do Vim colors look different inside and outside of tmux?

I had the similar issue before. Comments in blue in Vim were hard to read. In .tmux.conf I set this: set -g default-terminal "screen-256color" And in .vimrc: set background=dark Now it looks as ...
Vitali Plagov's user avatar
52 votes
Accepted

"/usr/bin/ping" is shown as yellow-on-red in the default Fedora bash color scheme -- what does it mean?

This indicates that ping has extra capabilities: $ getcap /usr/bin/ping /usr/bin/ping = cap_net_raw+ep or even (on Fedora up to 30): $ getcap /usr/bin/ping /usr/bin/ping = cap_net_admin,cap_net_raw+...
Stephen Kitt's user avatar
50 votes

What color codes can I use in my Bash PS1 prompt?

I wrote a bash function that can show you all the colors, if this helps. function colorgrid( ) { iter=16 while [ $iter -lt 52 ] do second=$[$iter+36] third=$[$second+36] ...
Plasmarob's user avatar
  • 609
44 votes

Getting 256 colors to work in tmux

As per the tmux FAQ, add this to your ~/.tmux.conf: set -g default-terminal "screen-256color" Then add this alias for tmux: alias tmux='tmux -2' No need to override the TERM variable in ...
user1338062's user avatar
38 votes

tput setaf color table? How to determine color codes?

The tput utility is using a 256-color lookup table to print 8-bit ANSI escape sequences (starting with Esc and [) which makes use of terminal capabilities, so these control sequences can be ...
kenorb's user avatar
  • 21.3k
35 votes

How to make Vim display colors as indicated by color codes?

Now with vim 8 you can use terminal mode :terminal and then in that terminal do cat myfile and go back to normal mode with Ctrl-w N. This will display ANSI color codes correctly. By automating these ...
Johannes Riecken's user avatar
35 votes

How to colorize output of git?

The accepted answer gives the most common solution. If for any reason you need not to permanently change the configuration, which that solution does, you may override the configuration for a single ...
Hamlet's user avatar
  • 471
34 votes

What causes this green background in ls output?

tldr; How to just fix it? To quickly fix the problem: LS_COLORS+=':ow=01;33' Makes other-writable files show up as yellow on nobg Edit your shell profile (e.g. ~/.bashrc, ~/.profile, etc) to make ...
loxaxs's user avatar
  • 1,964
34 votes
Accepted

Why do Vim colors look different inside and outside of tmux?

tmux doesn't support the terminfo capability bce (back color erase), which vim checks for, to decide whether to use its "default color" scheme. That characteristic of tmux has been mentioned a few ...
Thomas Dickey's user avatar
32 votes

How do I pipe colored diff output to less?

The other answers here might be out of date. As of coreutils 3.5 diff can indeed produce colored output which is turned off by default when the stdout is not a console. From the man page: --color[...
Kshitiz Sharma's user avatar
32 votes

Random colors and jokes in the shell/terminal

Running a ruby script on every login doesn't sound like my idea of a good time. But if it's colours you want you won't be disappointed by lolcat https://github.com/busyloop/lolcat DISCLAIMER: I have ...
batfastad's user avatar
  • 1,035
31 votes

Can less retain colored output?

In case anyone is interested in paging a json with jq and less it can be achieved using: jq -C <jq args> file.json | less -R e.g. jq -C . file.json | less -R Source: https://github.com/...
dimid's user avatar
  • 637
29 votes

Colors in Man Pages

The default underlines hurt my eyes. This setup greatly improves my man page reading: Add the following in your `~.bashrc': # Have less display colours # from: https://wiki.archlinux.org/index.php/...
Tom Hale's user avatar
  • 31.2k
28 votes
Accepted

How does a program decide whether or not to have coloured output?

Most such programs only output colour codes to a terminal by default; they check to see if their output is a TTY, using isatty(3). There are usually options to override this behaviour: disable colours ...
Stephen Kitt's user avatar
26 votes
Accepted

What does a red-colored filename mean?

First you need to know the VT100 color code https://en.wikipedia.org/wiki/ANSI_escape_code#Colors I don't know what your text actually looks like, but "red text" is 31. Then you want to look ...
hymie's user avatar
  • 1,740
25 votes

Removing control chars (including console codes / colours) from script output

There's an ansi2txt command in the colorized-logs package on Ubuntu. It removes ANSI color codes nicely, but it doesn't deal with things like progress bars produced by emitting ^H or ^M characters to ...
Marius Gedminas's user avatar
25 votes
Accepted

Urxvt: change background color on the fly

urxvt 2.6 in 2004 added support for xterm's dynamic colors feature. In XTerm Control Sequences, this is OSC 11. OSC 10 sets the default text color. The changelog mentioned part of the change: 2.6 ...
Thomas Dickey's user avatar
25 votes
Accepted

Print a 256-color test pattern in the terminal

256-colour test pattern For the above, you can use my bash code. ("Look Ma, no subprocesses!") Or for a bash quicky: for i in {0..255} ; do printf "\x1b[38;5;${i}m%3d " "${i}" if (( $i == ...
Tom Hale's user avatar
  • 31.2k
24 votes

How to colorize some of the output of a shell-script?

With zsh instead of bash: #! /bin/zsh - email="[email protected]" ips=(88.86.120.{212,223,250,213,103} 46.234.104.{23,24}) print '\n\n' for ip ($ips) { spfquery -sender $email -ip $ip -...
Stéphane Chazelas's user avatar
22 votes

How do you display xterm colors with putty/bash?

For me, I had to go into settings and set the terminal type. Settings -> Connection > Data > Terminal-type change to xterm-256color.
directedition's user avatar
22 votes
Accepted

Getting gcc piped-to-less to properly show colors on the terminal

Posting as an answer as requested. There are two problems here: By default gcc prints color codes only when the output is a terminal. By default less doesn't send raw color characters to the ...
Satō Katsura's user avatar
22 votes
Accepted

Clearing tmux terminal throws error: "'tmux-256color': unknown terminal type."

Your plaform doesn't have tmux-256color, you will need to either: 1) Use screen-256color instead. 2) See if you can upgrade ncurses or terminfo to a later version with tmux-256color. 3) Copy tmux-...
Nicholas Marriott's user avatar
21 votes

What causes this green background in ls output?

While all the technical answers are true, I would consider it a bit of an informal warning, that you dished out rights a bit to generously or copying criss+cross... (most often we all do, to get ...
Frank N's user avatar
  • 472
21 votes

Random colors and jokes in the shell/terminal

Text-mode graphics + jokes can be implemented using installing ponysay + fortune. The ponysay package by default displays a string picking up a random poney. Then for basic use, you do: fortune | ...
Rui F Ribeiro's user avatar
20 votes

Getting 256 colors to work in tmux

For people who have latest tmux, the .tmux.conf option from the accepted answer should work. I only want to add that you will probably need to restart tmux for the new configuration to take effect: ...
mast3r's user avatar
  • 301
19 votes

Can less retain colored output?

I know this is old and many have already provided the right answer but I would like to add that it is always better to use less -R and not less -r if you only need ANSI colors as -r may cause problems ...
Naheel's user avatar
  • 291

Only top scored, non community-wiki answers of a minimum length are eligible