Hi,
Can someone please tell me how to turn off/on all colors on Linux?
SO far, I've unset LS_COLORS and set TERM to xterm-mono or vt100.
vi appears to be plain, no colors, so that's good.
ls etc still appears in colors. I guess I have unalias all the alias that uses --color=auto? I thought unsetting LS_COLORS will take care of.
I just want a 'simple' sort of script that I can run to turn off/on colors.
Please advise. Thanks in advance.
To forgo using aliased commands, prepend the command with \
E.g.: \ls
Fight aliases with aliases.
#.. Define monochrome ls as lsm
alias lsm='ls --color=never'
paul: ~/spoom $ type -a ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
ls is /bin/ls
paul: ~/spoom $ type -a lsm
lsm is aliased to `ls --color=never'
paul: ~/spoom $
Because an alias may call an alias, consider
alias lsm='\ls --color=never'
My bad: should be --color=never. I fixed it in my test as shown, but failed to alter the text that was already in my post.
There is an oddity in your note about alias=>alias. I chose to allow this (i.e. not quote the aliased ls) so that any other args in an existing alias would work. Clearly, my default ls has --color=auto, and the normal convention is that last arg wins. But in this case, ls obeys the first color option (presumably to fix just this case).
Aliases can be lethal. I had a client (actually their senior developer) who was trying to force a rebuild on a remote machine, but kept deleting sources, libraries, and include files unintentionally. He was running a remote ls, checking the list, and then sending that back with a rm on the front.
Trouble was, the remote server had an alias ls -F, as part of the vendor's install. The indicator is * for executables, and that then became a wildcard on the rm command.
Haha, I blindly copied yours, assuming the =
Now corrected.
Yes, you should not trust the ls output, for many reasons.
And be extra careful with rm. E.g. first replace it with echo or better printf "%s\n".