How do I get a totally mono terminal? Preferably from an environment variable or just a tweak such that all terminal programs are mono.

I've tried this:

  1. export TERM=xterm-mono
  2. export LS_COLORS=""

The test to see if it works is to run w3m on a website and see if the color codes are still being used -- it is still being coloured.

  • I don't think I'm directly answering your question but the first thing I generally do on machines that aren't my own is set this by using unalias -a
    – Gtt
    May 1 '19 at 8:52
  • It actually depends on your terminal emulator, which one are you using? Maybe there's a config menu? May 1 '19 at 9:05
  • xterm has the -cm option to disable colours May 1 '19 at 10:03
  • You'd tagged xterm, kde, terminal, and gnome. Please spell out explicitly which GUI terminal you're using. (xterm, gnome-terminal, xfce4-terminal, etc)
    – Jeff Schaller
    May 1 '19 at 13:01
  • Right, i'm asking in general. So it appears that there's no way to disable terminal colours from the command line, because the escape codes are read when w3m emits them. The only way is freddy's answer. May 1 '19 at 15:11

In w3m you can turn off colors with option -o color=false or -M (monochrome display mode). It seems true is the default setting?

$ w3m -show-option | grep color
    -o color=<bool>                     Display with color
    -o basic_color=<color>              Color of normal character
    -o anchor_color=<color>             Color of anchor
    -o image_color=<color>              Color of image link
    -o form_color=<color>               Color of form
    -o mark_color=<color>               Color of mark
    -o bg_color=<color>                 Color of background
    -o active_style=<bool>              Enable coloring of active link
    -o active_color=<color>             Color of currently active link
    -o visited_anchor=<bool>            Use visited link color
    -o visited_color=<color>            Color of visited link

In Debian's /etc/skel/.bashrc are a few lines controlling the color depending on TERM, force_color_prompt (color_prompt) and existence of /usr/bin/dircolors. You probably have something similar on your system.

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;

# 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

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.)

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

# 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'

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

Exporting TERM=xterm-mono and deleting the lines above seems to work except for the colors in w3m.

  • I have found these same lines on occassions when I've sought to accomplish what the OP is after. My solution was to chmod -x /usr/bin/dircolors.
    – Jim L.
    May 1 '19 at 19:21

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.