I use default Linux Mint .bashrc, here is full bashrc, the output is like:
some dir has green background, How to remove it?
Enter these two commands in the Bash command line:
dircolors -p | sed 's/;42/;01/' > ~/.dircolors
source ~/.bashrc
There is a program dircolors
intended to set up the config for ls
.
The default ~/.bashrc
script loads the config with these lines:
# 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)"
Because by default the file ~/.dircolors
does not actually exist the script uses the built-in Bash config (eval "$(dircolors -b)"
).
To remove green background for o+w
('writable by others' permission marked by last 'w
' in drwxrwxrwx
notation in ls
) directories you need to create this file basing on the current (built-in) config. In the command line type the following:
dircolors -p > ~/.dircolors
dircolor -p
prints the current config and >
redirects the output to the given file.
Now open the file in an editor and find the following line:
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
change the number 42
(denoting green background) to 01
(no background) and save changes. Alternatively you can do it with sed
program and its substitution feature ('s/PATTERN/NEW_STRING/'
syntax) from the command line directly:
sed -i 's/;42/;01/' ~/.dircolors
Above 2 things can be achieved by a single command using a pipe '|
':
dircolors -p | sed 's/;42/;01/' > ~/.dircolors
To get the change to take the effect (without restarting the shell), type:
source ~/.bashrc
To remove all background colors, stick the following into your ~/.bashrc :
eval "$(dircolors -p | \
sed 's/ 4[0-9];/ 01;/; s/;4[0-9];/;01;/g; s/;4[0-9] /;01 /' | \
dircolors /dev/stdin)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With