Annoying colors on Linux command line

News Shells Recommended Links ls command dircolors  tree
Annoying colors in vim VIM Syntax Highliting Annoying colors in man Annoying colors in less tee Pipes
xargs find Exit Status Horror Stories Humor Etc

The Linux colorizing fouls things up royally. The the worst offender are ls and vim commands.

For ls can shut off command line colorizing by editing /etc/DIR_COLORS and changing "COLOR tty" to "COLOR none" or (less drastically) by adding the  --color=none, --color=tty or a similar option to the ls command. This is typically accomplished by creating an alias to ls in either the user’s profile or in one of the system-wide profiles.

alias ls='ls --color=none'

See ls command for details.

for VIM you can turn syntax coloring off, change color scheme and modify your vimrc file. See Annoying colors in vim

But that is only a tip of the iceberg. There are many programs that suffer from overzealous colorization. Among them:

There are two way diminish this nuisance

Setting black & white terminal requires some knowledge of terminals. You can get it from

Text-Terminal-HOWTO Terminal Set-Up (Configure) Details

Colours with Linux terminals How to change the text-mode default from white-on-black

How to change the text-mode default from white-on-black

You will need to tell the terminal driver code that you want another default. There exists no standard way of doing this, but in case of Linux you have the setterm program.

"setterm" uses the information in the terminal database to set the attributes. Selections are done like

setterm -foreground black -background white -store

where the "-store" besides the actual change makes it the default for the current console as well. This requires that the current terminal (TERM environment variable) is described "well enough" in the termcap database. If setterm for some reason does not work, here are some alternatives:

6.1 Xterm

One of these xterms should be available and at least one of them support colour.

xterm -fg white -bg blue4
color_xterm -fg white -bg blue4
color-xterm -fg white -bg blue4
nxterm -fg white -bg blue4

where 'color_xterm' supports the color version of 'ls'. This particular choice resembles the colors used on an SGI.

6.2 Virtual console.

You may modify the kernel once and for all, as well as providing a run-time default for the virtual consoles with an escape sequence. I recommend the kernel patch if you have compiled your own kernel.

The kernel source file is /usr/src/linux/drivers/char/console.c around line 1940, where you should modify

        def_color       = 0x07;   /* white */
        ulcolor         = 0x0f;   /* bold white */
        halfcolor       = 0x08;   /* grey */
as appropriate. I use white on blue with
        def_color       = 0x17;   /* white */
        ulcolor         = 0x1f;   /* bold white */
        halfcolor       = 0x18;   /* grey */

The numbers are the attribute codes used by the video card in hexadecimal: the most significant digit (the "1" in the example colours above) is the background; the least significant the foreground. 0 = black, 1 = blue, 2 = green, 3 = cyan, 4 = red, 5 = purple, 6 = brown/yellow, 7 = white. Add 8 to get "bright" colours.

Note that, in most cases, a bright background == blinking characters, dull background. (From [email protected]).

You may also supply a new run-time default for a virtual console, on a per-display basis with the non-standard ANSI sequence (found by browsing the kernel sources)

        ESC [ 8 ]

which sets the default to the current fore- and background colours. Then the Reset Attributes string (ESC [ m) selects these colours instead of white on black.

You will need to actually echo this string to the console each time you reboot. Depending on what you use your Linux box for, several places may be appropriate:

/etc/issue

This is where "Welcome to Linux xx.yy" is displayed under Slackware, and that is a good choice for stand-alone equipment (and probably be a pestilence for users logging in with telnet). This file is created at boottime (Slackware in /etc/rc.d/rc.S; Redhat in /etc/rc.d/rc.local), and you should modify lines looking somewhat like

  echo ""> /etc/issue
  echo Welcome to Linux `/bin/uname -a | /bin/cut -d\  -f3`. >> /etc/issue
to
  ESCAPE="<replace with a single escape character here>"
  echo "${ESCAPE}[H${ESCAPE}[37;44m${ESCAPE}[8]${ESCAPE}[2J"> /etc/issue
  echo Welcome to Linux `/bin/uname -a | /bin/cut -d\  -f3`. >> /etc/issue

This code will home the cursor, set the colour (here white on blue), save this selection and clean the rest of the screen. The modification takes effect after the next reboot. Remember to insert the _literal_ escape character in the file with C-q in emacs or control-v in vi, as apparently the sh used for executing this script does not understand the /033 syntax.

/etc/profile or .profile

  if [ "$TERM" = "console" ]; then
      echo "\033[37;44m\033[8]" #
# or use setterm.
      setterm -foreground white -background blue -store
  fi

/etc/login or .login

  if ( "$TERM" == "console" ) then
    echo "\033[37;44m\033[8]"  
# or use setterm.
      setterm -foreground white -background blue -store
  endif

6.3 Remote login

You should be able to use the setterm program as shown above. Again, this requires that the remote machine knows enough about your terminal, and that the terminal emulator providing the login supports colour.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

HowTo Turn On or Off Colors For ls Command In Bash On a Linux and Unix-like Systems

cyberciti.biz

Task: Turn off colors for ls command

Type the following command

$ ls --color=none

Or just remove alias with unalias command:

$ unalias ls

Task: Turn on colors for ls command

Use any one of the following command:

$ ls --color=auto
$ ls --color=tty

Directory colors have been annoying me

FedoraForum.org

glennzo Online
Un-Retired Administrator Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,837
linuxfirefox

Directory colors have been annoying me

--------------------------------------------------------------------------------

I didn't like the fact that folders on my NTFS partitions were shown in blue on a green background. I though that this was just plain ugly. I set out to change that.

In the file /etc/DIR_COLORS there is a line that reads:


PHP Code:
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky

A far as I can tell this is the line that is responsible for the ugly blue on green background display. I changed it so that there was essentially no background color. Just blue text. The edited line then is:


PHP Code:
OTHER_WRITABLE 34;1 # dir that is other-writable (o+w) and not sticky

To see the change I needed to close and re-open the terminal. I'm happy again, at least for a few minutes or until someone tells me my method is just plain wrong, and can now function as a productive member of society.

Is this the proper method? No freakin' idea.
Did I get the desired results? Yep.
Will I be proven wrong at some point? Probably.
Do I care? Nope.

Just thought I'd share in case anyone else despises the blue on green text.
__________________
Glenn
The Bassinator © ®
[SIGPIC][/SIGPIC]
Laptop: Just a couple of old single core units
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / Kingston HyperX 3K SSD 240GB SATA 3.0 / 1TB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote

glennzo
View Public Profile
Find all posts by glennzo

#2 Old 21st April 2012, 02:46 PM
PabloTwo Offline
"Registered User" T-Shirt Winner Join Date: Mar 2007
Location: Seville, FL
Posts: 6,203
linuxchrome

Re: Directory colors have been annoying me

--------------------------------------------------------------------------------

That's basically correct. There are some old moldy threads here on the forum discussing this. What I always do is to make a copy of /etc/DIR_COLORS to ~/.dir_colors, then edit the file in my home directory.

To make the ntfs directories appear as the same color as your other directories, the color code to use is:

Code:
OTHER_WRITABLE 01;34 # dir that is other-writable (o+w) and not sticky.

You can see the default directory color code with the command "dircolors -p". Near the top of the output, you'll see this:

Code:
DIR 01;34 # directoryReply With Quote

PabloTwo
View Public Profile
Find all posts by PabloTwo

#3 Old 21st April 2012, 03:56 PM
glennzo Online
Un-Retired Administrator Join Date: Mar 2004
Location: Salem, Mass USA
Age: 57
Posts: 14,837
linuxubuntuchrome

Re: Directory colors have been annoying me

--------------------------------------------------------------------------------

Thanks for the tips PabloTwo
__________________
Glenn
The Bassinator © ®
[SIGPIC][/SIGPIC]
Laptop: Just a couple of old single core units
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / Kingston HyperX 3K SSD 240GB SATA 3.0 / 1TB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote

glennzo
View Public Profile
Find all posts by glennzo

#4 Old 21st April 2012, 04


Recommended Links

Top Visited

Bulletin Latest Past week Past month
Google Search





Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019