First, you will want to make sure that you don't have an alias setup. An alias is a shortcut to a command. Type 'alias' to give you a list.
In Red Hat Linux and Fedora, those aliases are being set by the /etc/profile.d/colorls.sh and /etc/profile.d/which-2.sh scripts, which are called from the following section of /etc/profile:
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
doneThat little snippet basically says: "for every file which can be read in
/etc/profile.d/, source that file".
One way to get around this would be to comment out the lines in those scripts which set the aliases you want to over-ride.
I commented out the following lines in /etc/profile to disable color scheme globally:
#for i in /etc/profile.d/*.sh ; do
# if [ -r "$i" ]; then
# . $i
# fi
#done
To reset your terminal color scheme, append '\e[0m' to your PS1 environment variable.
Example:
export PS1=$PS1'\e[0m'
Colors are selected by adding special sequences to PS1 -- basically sandwiching
numeric values between a "\e[" (escape open-bracket) and an "m". If we specify more
than one numeric code, we separate each code with a semicolon. Here's an example
color code:
When we specify a zero as a numeric code, it tells the terminal to reset foreground,
background, and boldness settings to their default values. You'll want to use this
code at the end of your prompt, so that the text that you type in is not colorized.
Now, let's take a look at the color codes. This:
becomes:
export PS1="\e[32;40m\w> "
|
So far, so good, but it's not perfect yet. After bash prints the working directory,
we need to set the color back to normal with a "\e[0m" sequence:
export PS1="\e[32;40m\w> \e[0m"
|
This definition will give you a nice, green prompt, but we still need to add a few
finishing touches. We don't need to include the background color setting of 40,
since that sets the background to black which is the default color anyway. Also,
the green color is quite dim; we can fix this by adding a "1" color code, which
enables brighter, bold text. In addition to this change, we need to surround all
non-printing characters with special bash escape sequences, "\[" and "\]". These
sequences will tell bash that the enclosed characters don't take up any space on
the line, which will allow word-wrapping to continue to work properly. Without them,
you'll end up with a nice-looking prompt that will mess up the screen if you happen
to type in a command that approaches the extreme right of the terminal. Here's our
final prompt:
export PS1="\[\e[32;1m\]\w> \[\e[0m\]"
|
Don't be afraid to use several colors in the same prompt, like so:
export PS1="\[\e[36;1m\]\u@\[\e[32;1m\]\H> \[\e[0m\]"
|