Disable color in shell/terminal

14

2

I want to disable all color in my shell. Not ls, not nano, not vi, nothing. What's the best way to achieve this?

Poe

Posted 2011-04-06T01:26:11.313

Reputation: 243

Answers

7

if you are using PUTTY to remotely access the shell, then:
- on the left panel, click Colors
- uncheck the three boxes on the right panel (they are checked by default)

Beel

Posted 2011-04-06T01:26:11.313

Reputation: 303

I'll have to switch to a terminal program that lets me do this. Thanks. – Poe – 2011-04-06T01:57:27.737

1Geekosaur's answer is better for you, really. – ocodo – 2011-04-06T03:21:03.833

@slomojo his answer didn't work with my terminal client – Poe – 2011-04-06T09:46:45.473

1Oh, interesting, which client is it? – ocodo – 2011-04-06T10:37:31.407

I'm using iTerm (OS X) and still getting color if I export TERM=vt220, and in 'ls' even after unsetting LS_COLORS – Poe – 2011-04-07T03:42:40.570

Same thing for me using Putty from Windows XP into a Centos 5.5 system. In other words, the ls command still gives colors after unsetting LS_COLORS.<br />Poe, if my answer works for you, please choose it as the answer. – Beel – 2011-04-10T00:12:10.977

13

unset LS_COLORS; export TERM=xterm should do it, or at least get you most of the way there. You may need to change that to say TERM=vt220 for some overly "smart" programs.

geekosaur

Posted 2011-04-06T01:26:11.313

Reputation: 10 195

3Definitely recommend VT220 over XTERM. – ocodo – 2011-04-06T03:20:23.927

6"xterm" is a color terminal, to disable colors you need TERM=xterm-mono – Idelic – 2011-04-11T21:37:41.730

6

xterm -cm

This will start an xterm with no colors.

Rajat Bhatia

Posted 2011-04-06T01:26:11.313

Reputation: 61

This won't work if you have LS_COLORS set FYI. – lzap – 2016-10-14T14:22:07.603

This is the best answer. Also, @lzap appears to be incorrect, at least on Ubuntu. xterm -cm give me a no-color terminal on Ubuntu regardless of LS_COLORS. – Haydentech – 2019-07-17T19:49:47.893

Well I meant that it will break terminal on Red Hat systems with LS_COLORS set by default. – lzap – 2019-08-15T13:01:06.257

1

I encountered the same problem while writing an SSH robot in Python (colors came out as jibberish when run through Visual Studio). The simplest solution was to open a new shell inside the other shell that was running.

sh

This opened a fresh shell without any of my settings and all printouts was monochrome. It also reset the prompt which was a bonus for my intended purpose.

Lord Wolfenstein

Posted 2011-04-06T01:26:11.313

Reputation: 151

1

make a backup of .bashrc and then open .bashrc and remove all of these lines. this has the added benefit of disabling text colors in gedit!

set a fancy prompt (non-color, unless we know we "want" color)

case "$TERM" in xterm|xterm-color|*-256color) color_prompt=yes;; esac

uncomment for a colored prompt, if the terminal has the capability; turned

off by default to not distract the user: the focus in a terminal window

should be on the output of commands, not on the prompt

force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi

if [ "$color_prompt" = yes ]; then if [[ ${EUID} == 0 ]] ; then PS1='${debian_chroot:+($debian_chroot)}[\033[01;31m]\h[\033[01;34m] \W \$[\033[00m] ' else PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m] [\033[01;34m]\w \$[\033[00m] ' fi else PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ ' fi unset color_prompt force_color_prompt 42a70,89

If this is an xterm set the title to user@host:dir

case "$TERM" in xterm*|rxvt*) PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \w\a]$PS1" ;; *) ;; esac

enable color support of ls and also add handy aliases

if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' #alias dir='dir --color=auto' #alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

fi

Al Brundage

Posted 2011-04-06T01:26:11.313

Reputation: 11