[opensuse] ls command - disable color coding
Is there a way to disable color coding in the 'ls' command permanently? It's giving me such lovely colors across my gnome-terminal but very unreadable with my sight. :-) The only thing I've found so far is that it is driven by the ls_colors environment variable as seen by the 'dircolors' command. But that's where I am stumped. Typing dircolors or dircolors --print-database outputs all the color codes specified for each filetype, but not how to permanently disable it. I have tried 'ls --color=none' and 'ls --color=never' but both apparently are on a per command basis and don't stick when running ls again. Per the 'ls' manpages (which I don't think is true here.) "By default, color is not used to distinguish types of files. That is equivalent to using --color=none. Using the --color option without the optional WHEN argument is equivalent to using --color=always." Thanks in advance folks! -- ---Bryen--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 17 October 2007 16:27:16 Bryen wrote:
Is there a way to disable color coding in the 'ls' command permanently? It's giving me such lovely colors across my gnome-terminal but very unreadable with my sight. :-)
Usually "ls" is an alias to "/bin/ls", but with some additional options. Try "alias ls" what they are on your system. On mine, I get alias ls='ls $LS_OPTIONS' where LS_OPTIONS="-N --color=tty -T 0". This is set in /etc/bash.bashrc. You can temper with this file, but the easiest way to disable colors permanently is to create an empty ".dir_colors" file in your home directory ("touch .dir_colors").
Per the 'ls' manpages (which I don't think is true here.) "By default, color is not used to distinguish types of files. That is equivalent to using --color=none. Using the --color option without the optional WHEN argument is equivalent to using --color=always."
The problem is probably that you are not calling /bin/ls, but the alias, which specifies when to user color. Hope this helps, Lutz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
[Bryen]
Is there a way to disable color coding in the 'ls' command permanently?
Short of modifying and recompiling the code (from GNU coreutils), you might add something like this (untested) in your ~/.bashrc file: ls() { /bin/ls --color=none "$@"; } and then, you should not get colors when working interactively. In my own case, I not only like having colors, but activate a few other options as well, depending on a few various contexts and systems, as shown below -- you do not want it, but it might trigger other ideas :-). ls() { local options='--show-control --quoting-style=literal' if test -t 1; then options="$options -Nx" else options="$options -N" fi if [ "$TERM" != dumb ]; then options="$options --color=auto" fi if /bin/ls --help | /bin/grep -s -- --time-style >/dev/null; then options="$options --time-style='+%Y-%m-%d %H:%M'" fi eval /bin/ls $options "$@" } -- François Pinard http://pinard.progiciels-bpi.ca -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2007-10-17 at 19:43 -0400, François Pinard wrote:
[Bryen]
Is there a way to disable color coding in the 'ls' command permanently?
Short of modifying and recompiling the code (from GNU coreutils), you might add something like this (untested) in your ~/.bashrc file:
ls() { /bin/ls --color=none "$@"; }
and then, you should not get colors when working interactively.
I tried that line and it didn't work, tried it in various tinkerings and it still didn't work. Then again, you did say "untested." :-) Regardless, you all pointed me in the right direction and I was able to locate the LS color section in /etc/bash.bashrc. I changed the following: if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then LS_OPTIONS=--color=tty <--- (CHANGED TTY TO NONE) That did the trick. I suppose I should follow Patrick's suggestion and copy the entire LS section to bash.bashrc.local so I won't lose my changes in an update. This seems less volatile than creating an empty LS_Colors file and losing all those other colors for another user. Thanks for all your help.
---Bryen---
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 * Bryen <suseROCKS@bryen.com> [10-17-07 20:37]:
Regardless, you all pointed me in the right direction and I was able to locate the LS color section in /etc/bash.bashrc. I changed the following:
if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then LS_OPTIONS=--color=tty <--- (CHANGED TTY TO NONE)
That did the trick. I suppose I should follow Patrick's suggestion and copy the entire LS section to bash.bashrc.local so I won't lose my changes in an update.
20:43 wahoo:~ > head /etc/bash.bashrc # /etc/bash.bashrc for SuSE Linux # # PLEASE DO NOT CHANGE /etc/bash.bashrc There are chances that your changes # will be lost during system upgrades. Instead use /etc/bash.bashrc.local # for your local settings, favourite global aliases, VISUAL and EDITOR # variables, etc ... - -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn4472 (GNU/Linux) iD8DBQFHFqxwClSjbQz1U5oRAkmiAJ9gFwM6X/x5RPxn4a+7Ps9AqEi5pQCfbrGa uaZld0/abkoAaZNp29zjbK8= =Gawp -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 17 October 2007 17:34:58 Bryen wrote:
Regardless, you all pointed me in the right direction and I was able to locate the LS color section in /etc/bash.bashrc. I changed the following:
if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then LS_OPTIONS=--color=tty <--- (CHANGED TTY TO NONE)
That did the trick. I suppose I should follow Patrick's suggestion and copy the entire LS section to bash.bashrc.local so I won't lose my changes in an update.
This seems less volatile than creating an empty LS_Colors file and losing all those other colors for another user.
These are exactly the two reasons why I prefer a .dir_colors file: it's in your home directory, and even if you reinstall from scratch the setting persists as long as you keep /home. And it is specific to a single user. Lutz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2007-10-17 at 17:50 -0700, Lutz Maibaum wrote:
On Wednesday 17 October 2007 17:34:58 Bryen wrote:
Regardless, you all pointed me in the right direction and I was able to locate the LS color section in /etc/bash.bashrc. I changed the following:
if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then LS_OPTIONS=--color=tty <--- (CHANGED TTY TO NONE)
That did the trick. I suppose I should follow Patrick's suggestion and copy the entire LS section to bash.bashrc.local so I won't lose my changes in an update.
This seems less volatile than creating an empty LS_Colors file and losing all those other colors for another user.
These are exactly the two reasons why I prefer a .dir_colors file: it's in your home directory, and even if you reinstall from scratch the setting persists as long as you keep /home. And it is specific to a single user.
Lutz
Lutz, Okay, I tried your method after backing out everything I did earlier. I do like your method and it is nice and easy and definitely not volatile. Except that this isn't global. If I su, then the colors come back on me. Any suggestions on how to make this global? Useful on a machine that only I use but might have multiple profiles for various reasons. Thanks again for your suggestion. -- ---Bryen--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 17 October 2007 18:20:57 Bryen wrote:
On Wed, 2007-10-17 at 17:50 -0700, Lutz Maibaum wrote:
These are exactly the two reasons why I prefer a .dir_colors file: it's in your home directory, and even if you reinstall from scratch the setting persists as long as you keep /home. And it is specific to a single user.
Any suggestions on how to make this global?
If you want a global change, you can delete the content of /etc/DIR_COLORS. The file itself has to exist, so you could try mv /etc/DIR_COLORS /etc/DIR_COLORS.bak touch /etc/DIR_COLORS as root. Hope this helps, Lutz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2007-10-17 at 18:34 -0700, Lutz Maibaum wrote:
On Wednesday 17 October 2007 18:20:57 Bryen wrote:
On Wed, 2007-10-17 at 17:50 -0700, Lutz Maibaum wrote:
These are exactly the two reasons why I prefer a .dir_colors file: it's in your home directory, and even if you reinstall from scratch the setting persists as long as you keep /home. And it is specific to a single user.
Any suggestions on how to make this global?
If you want a global change, you can delete the content of /etc/DIR_COLORS. The file itself has to exist, so you could try
mv /etc/DIR_COLORS /etc/DIR_COLORS.bak touch /etc/DIR_COLORS
as root.
Hope this helps,
Lutz
Lutz, You and everyone else have been a great help. I weighed everyone's suggestions and decided I wanted to make this function less volatile but more flexible. (Just in case I need to enable colors again.) The /etc/DIR_COLORS suggestion just didn't cut it for me. So I created aliases in a .alias file and saved a copy of it to /root, /etc/skel and any existing user directories. The aliases in the file are as follows: # These aliases give add/remove color functionality to the 'ls' command. # The presence of an empty .dir_colors file in a user's home directory # disables color functionality. # Double aliases created in case user forgets to add 's' to 'color' # Created: 10/17/2007 alias addcolor='rm -f ~/.dir_colors | echo "Colors added. You must restart your session before it takes effect."' alias addcolors='rm -f ~/.dir_colors | echo "Colors added. You must restart your session before it takes effect."' alias removecolor='touch ~/.dir_colors | echo "Colors removed. You must restart your session before it takes effect."' alias removecolors='touch ~/.dir_colors | echo "Colors removed. You must restart your session before it takes effect."' Works like a charm in root, existing users and new users testing. -- ---Bryen--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 17 Oct 2007, Bryen wrote:-
Okay, I tried your method after backing out everything I did earlier. I do like your method and it is nice and easy and definitely not volatile.
Except that this isn't global. If I su, then the colors come back on me.
That's because you need to create the same empty .dir_colors in /root. As root, type: touch ~/.dir_colors and you'll get the same effect as a normal user.
Any suggestions on how to make this global? Useful on a machine that only I use but might have multiple profiles for various reasons.
If you haven't already created the users, using touch /etc/skel/.dir_colors will ensure that all new users will get the empty file. If you already have the other users created, log in as each user and repeat the same touch command as for root. Regards, David Bolt -- Team Acorn: http://www.distributed.net/ OGR-P2 @ 100Mnodes RC5-72 @ 15Mkeys SUSE 10.0 32bit | SUSE 10.1 32bit | openSUSE 10.2 32bit | openSUSE 10.3 32bit SUSE 10.0 64bit | SUSE 10.1 64bit | openSUSE 10.2 64bit | RISC OS 3.11 | RISC OS 3.6 | TOS 4.02 | openSUSE 10.3 PPC -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
[Bryen]
On Wed, 2007-10-17 at 19:43 -0400, François Pinard wrote:
[Bryen]
Is there a way to disable color coding in the 'ls' command permanently?
Short of modifying and recompiling the code (from GNU coreutils), you might add something like this (untested) in your ~/.bashrc file:
ls() { /bin/ls --color=none "$@"; }
and then, you should not get colors when working interactively.
I tried that line and it didn't work, tried it in various tinkerings and it still didn't work. Then again, you did say "untested." :-)
Hello, Bryen. A bit teased by your remark :-), I tried it here, and it works for me. However, Ti Kan (in this thread) probably put the finger on the real problem, which is that "ls" has to be unaliased first. Long ago, when SuSE was still a small shop, I asked for all aliases to be turned into shell functions in the distributed SuSE, and they did so in the release which followed. But, a few releases later, the aliases returned, and I did not insist for them to disappear again. But on my side, I unalias everything at the start of my .bashrc file, and did it for so long that I forgot about it, sorry! The reason I dislike aliases is that they sometimes get the bash syntax analyzer to misbehave in unexpected ways, while shell functions are much more regular and predictable in that respect. I did not use aliases in years, and surely spared myself trouble by sticking to my decision :-). -- François Pinard http://pinard.progiciels-bpi.ca -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 * Bryen <suseROCKS@bryen.com> [10-17-07 19:27]:
Is there a way to disable color coding in the 'ls' command permanently? It's giving me such lovely colors across my gnome-terminal but very unreadable with my sight. :-)
/etc/bash.bashrc but decide on your changes and put them into /etc/bash.bashrc.local then system updates to /etc/bash.bashrc will not change your choices. - -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn4472 (GNU/Linux) iD8DBQFHFqBOClSjbQz1U5oRAujvAJ9sV4wR5yHGjei1/QrImSd/jgcGngCfbf6F RyvU0Al82qn9Y+Vp6pRuv8g= =w5SO -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Bryen writes:
Is there a way to disable color coding in the 'ls' command permanently? It's giving me such lovely colors across my gnome-terminal but very unreadable with my sight. :-)
unalias ls -Ti -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Oct 17 2007 18:27, Bryen wrote:
Is there a way to disable color coding in the 'ls' command permanently? It's giving me such lovely colors across my gnome-terminal but very unreadable with my sight. :-)
Then perhaps try a black background. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (7)
-
Bryen
-
David Bolt
-
François Pinard
-
Jan Engelhardt
-
Lutz Maibaum
-
Patrick Shanahan
-
ti@amb.org