On my console the color for directories is such a blue, that it is hard to read on a dark background.
How can I change the color definitions for ls
?
On my console the color for directories is such a blue, that it is hard to read on a dark background.
How can I change the color definitions for ls
?
To change your directory colors, open up your
~/.bashrc
file with your editorand make the following entry at the end of the file:
Some nice color choices (in this case
0;35
it is purple) are:The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:
The possible backgrounds:
All possible colors:
These can even be combined, so that a parameter like:
in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!
To test all these colors and styles in your terminal, you can use one of:
You can also change other kinds of files when using the ls command by defining each kind with:
A more complete list is available at Bigsoft - Configuring LS_COLORS.
On some distributions, you might also want to change the background color for
ow
"(OTHER_WRITABLE
) whose default is non-readable" for example to non-bold blue text on green background.You could use for instance
LS_COLORS="$LS_COLORS:di=1;33"
at the end of your.bashrc
file, to get a nice readable bold orange text on black background.After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run
source ~/.bashrc
.Note: You can combine more commands with a colon, for example
Source:
Very simple. Add these three lines to ~/.bashrc
If you want to apply the changes in a running bash session, run:
Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.
You can create a .dircolor file in your home directory as follows:
Then in your ~/.bashrc file add the lines
This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.
Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours). You can also change the colours of specific files, or define your own.
LS_COLORS
This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.
I don't like removing all colors because they are still useful. I prefer to keep current defaults and just remove the green background on directories. For this effect I just add one line to the end of my
~/.bashrc
:The
--color=auto
option doesn't work for me using iTerm2 on my Mac. The-G
option works though. I put the following alias in my~/.profile
and now directories are colored and have a trailing/
appended:For the instant solution,
--color=auto
may make no difference. The option you want is--color=never
. Though piping the output throughcat
(ormore
) would also remove the colouring, and is quicker to type:(I don't know who's idea of a joke it was to make light blue against light green the default.)
The is my approach for ls command with commonly used options:
add the following lines into a file called ~/.alias
add the following lines into ~/.bashrc
Put below line into ~/.bashrc you are done.
To enable color prompt put one line below
Vivid makes the process of changing
ls
's colors nice and easy.Install with: