14

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

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)

| improve this answer | |
  • I'll have to switch to a terminal program that lets me do this. Thanks. – Poe Apr 6 '11 at 1:57
  • 1
    Geekosaur's answer is better for you, really. – ocodo Apr 6 '11 at 3:21
  • @slomojo his answer didn't work with my terminal client – Poe Apr 6 '11 at 9:46
  • 1
    Oh, interesting, which client is it? – ocodo Apr 6 '11 at 10:37
  • I'm using iTerm (OS X) and still getting color if I export TERM=vt220, and in 'ls' even after unsetting LS_COLORS – Poe Apr 7 '11 at 3:42
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.

| improve this answer | |
  • 3
    Definitely recommend VT220 over XTERM. – ocodo Apr 6 '11 at 3:20
  • 6
    "xterm" is a color terminal, to disable colors you need TERM=xterm-mono – Idelic Apr 11 '11 at 21:37
6
xterm -cm

This will start an xterm with no colors.

| improve this answer | |
  • This won't work if you have LS_COLORS set FYI. – lzap Oct 14 '16 at 14:22
  • 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 Jul 17 '19 at 19:49
  • Well I meant that it will break terminal on Red Hat systems with LS_COLORS set by default. – lzap Aug 15 '19 at 13:01
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.

| improve this answer | |
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

# 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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.