Tag Info

Hot answers tagged

85

The tmux FAQ ( http://tmux.cvs.sourceforge.net/viewvc/tmux/tmux/FAQ ) explicitly advises against setting TERM to anything other than screen or screen-256color in your shell init file, so don't do it! Here's what I use: ~$ which tmux tmux: aliased to TERM=xterm-256color tmux and in in my .tmux.conf: set -g default-terminal "screen-256color" Aliasing ...


80

Try out multitail. This is an übergeneralization of tail -f. You can watch multiple files in separate windows, highlight lines based on their content, and more. multitail -c /path/to/log The colors are configurable. If the default color scheme doesn't work for you, write your own in the config file. For example, call multitail -cS amir_log /path/to/log ...


56

Use: git diff --color=always | less -r --color=always is there to tell git to output color codes even if the output is a pipe (not a tty). And -r is there to tell less to interpret those color codes and other escape sequences. Use -R for ANSI color codes only.


42

Here are a couple of things you can do: Editors + Code A lot of editors have syntax highlighting support. vim and emacs have it on by default. You can also enable it under nano. You can also syntax highlight code on the terminal by using Pygments as a command-line tool. grep grep --color=auto highlights all matches. You can also use export ...


34

You need to use the termcap(5) feature. The man page on some Unices says this tool is obsolete and to use terminfo, but it's still available on others, and terminfo is more complicated. Most importantly, less uses termcap. I do the following so that less and man (which uses less) will have color: $ cat ~/.LESS_TERMCAP export LESS_TERMCAP_mb=$(tput bold; ...


32

You probably want to use git config --global color.ui auto The auto part says that git will only try and use color on terminals that support it, and you will not get ansi sequences if you redirect output of git commands to a file for example. The color.ui is a meta configuration that includes all the various color.* configurations available with git ...


31

You'd think there'd be a utility for that, but I couldn't find it. However, this Perl one-liner should do the trick: perl -pe 's/\e\[?.*?[\@-~]//g' Example: $ command-that-produces-colored-output | perl -pe 's/\e\[?.*?[\@-~]//g' > outfile Or, if you want a script you can save as stripcolorcodes: #! /usr/bin/perl use strict; use warnings; while ...


31

grc, the generic colouriser is pretty cool http://korpus.juls.savba.sk/~garabik/software/grc.html Just do grc tail -f /var/log/apache2/error.log and enjoy


30

You can create a section [color] in your ~/.gitconfig with e.g. the following content [color] diff = auto status = auto branch = auto interactive = auto ui = true pager = true You can also fine control what you want to have coloured in what way, e.g. [color "status"] added = green changed = red bold untracked = magenta bold [color ...


22

Check out stderred. It uses LD_PRELOAD to hook to libc's write() calls, colorizing all stderr output going to a terminal. (In red by default.)


20

I also use: export TERM=xterm-color export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32' export CLICOLOR=1 export LSCOLORS=ExFxCxDxBxegedabagacad And if you like colorizing your prompt, defined color vars can be useful: export COLOR_NC='\e[0m' # No Color export COLOR_WHITE='\e[1;37m' export COLOR_BLACK='\e[0;30m' export COLOR_BLUE='\e[0;34m' export ...


20

Have you had a look at ccze? You have the possibility to customize the default colors of some keywords using the option -c or directly in your configuration file. Edit: If you really would like to have the complete line colored in red, you could also have a try at the following: $ tail -f myfile.log | perl -pe 's/.*SEVERE.*/\e[1;31m$&\e[0m/g' ...


20

This is a harder version of Show only stderr on screen but write both stdout and stderr to file. The applications running in the terminal use a single channel to communicate with it; the applications have two output ports, stdout and stderr, but they're both connected to the same channel. You can connect one of them to a different channel, add color to ...


20

There are many options given in the manual. (See the OPTIONS section.) Create an RC file: ~/.tmux.conf. The contents below enables UTF-8, sets the right TERM type, and draws the status bar with a black background and white foreground. set status-utf8 on set utf8 on set -g default-terminal "screen-256color" set -g status-bg black set -g status-fg white ...


17

There are several different implementations of color for ls, and you've conflated some of them. On FreeBSD and Mac OS X, ls shows colors if the CLICOLOR environment variable is set or if -G is passed on the command line. The actual colors are configured through the LSCOLORS environment variable (built-in defaults are used if this variable is not set). To ...


17

Try setting 256 colors explicitly in your bashrc or zshrc: export TERM=xterm-256color or export TERM=screen-256color If you have problems with tmux not clearing the background colors correctly when using the screen term setting, you can try: export TERM=screen-256color-bce


17

I've found that the best way to pimp grep is to use ack, which is essentially recursive grep with an intelligent ignore list (e.g., doesn't search .svn directories, ignores backup files, etc.), colour highlighting of results and perl regexps. It's what you want grep to do 98.6% of the time.


17

The following script should filter out all ANSI/VT100/xterm control sequences for (based on ctlseqs). Minimally tested, please report any under- or over-match. #!/usr/bin/env perl while (<>) { s/ \e[ #%()*+\-.\/]. | (?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd (?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL) ...


17

You're seeing the escape sequences that tell the terminal to change colors displayed with the escape character shown as ESC, whereas the desired behavior would be that the escape sequences have their intended effect. Commands such as git diff and git log pipe their output into a pager, less by default. Git tries to tell less to allow control characters to ...


16

If you are wanting to change your colours in the console, that is outside X, then you can specify colours in your .bashrc, like so: if [ "$TERM" = "linux" ]; then echo -en "\e]P0222222" #black echo -en "\e]P8222222" #darkgrey echo -en "\e]P1803232" #darkred .... fi Where you are defining black as #222222 See this post for the details: ...


16

There are many color schemes which are usually distributed together with vim. You can select them with the :color command. You can see the available color schemes in vim's colors folder, for example in my case: $ ls /usr/share/vim/vimNN/colors/ # where vimNN is vim version, e.g. vim74 blue.vim darkblue.vim default.vim delek.vim desert.vim elflord.vim ...


16

Using GNU grep for the colouring: color() { GREP_COLOR=$1 grep --color '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log | color 33) Note that the first 2 are started in background. That means they won't be killed if you press Ctrl-C (shell explicitly ignore SIGINT for ...


15

Remove color codes (special characters) with sed sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" Or Strip ANSI escape sequences in Python Install colorama python package (pip install colorama). Put into stripcolorcodes: #!/usr/bin/env python import colorama, fileinput, sys; colorama.init(strip=True); for line in fileinput.input(): ...


15

Many programs that generate colored output detect if they're writing to a TTY, and switch off colors if they aren't. This is because color codes are annoying when you only want to capture the text, so they try to "do the right thing" automatically. The simplest way to capture color output from a program like that is to tell it to write color even though ...


15

Solarized gives very specific colours. You can't really achieve these colours in a standard 256 colour palette. The only way you can achieve this is through setting up the exact colours in your terminal emulator, then apps think they're just using standard 16 colours (8 + 8 brights) but these have been accurately mapped to the Solarized palette. Gnome ...


14

You can modify the color theme of vim with the background option. Use set background=dark in your current session or set it permanent in your vimrc. The output of ls is configured with /etc/DIR_COLORS. See the manpage for more information. The settings can be overwritten with a ~/.dir_colors (On Ubuntu: ~/.dircolors - see entry in ~/.bashrc) file in ...


13

install the package named as: colortest and enjoy coloring by running the binaries like colortest-8 colortest-16 colortest-16b and so on


12

If you can install the Term::ANSIColor module, this perl script works: #!/usr/bin/env perl use Term::ANSIColor qw(colorstrip); print colorstrip $_ while <>;


12

Could be a number of problems. Seeing as you're using zsh, try putting this in your ~/.zshrc: export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;47;34m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' export LESS=-r Then ...


12

This should be enough: $ tput colors tput colors explained: If you look at the manpage, you'ill notice this: SYNOPSIS tput [-Ttype] capname [parms ... ] And... capname indicates the capability from the terminfo database. When term‐ cap support is compiled in, the termcap name for the capability is also ...



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