solaris让ls命令显示颜色( 二 )


.xpm 01;35
.png 01;35
.tif 01;35

6. Test that your new setup works, using the /usr/local/bin/ls --color command in a couple of directorIEs.

If your colours seem ok (look also at other than plain text files), proceed to the next step.

7. Now we don"t want to type /usr/local/bin/ls --color all the time. You can solve the problem by altering your PATH variable:

user@host ~> export PATH=/usr/local/bin:$PATH

This way, when you just type ls, the first occurance in your search path will be the ls from /usr/local/bin instead of the default one from /usr/bin.

8. Now we already have the correct program when we call it, but we are lazier than that, because we don"t want to type the --color option all the time either. So you might want to alias the ls command:

user@host ~> alias ls="ls --color"

Mind that this does not work for the common shell, /sbin/sh. You need a more advanced shell for making aliases, such as bash or ksh.

9. Of course, when you log out, all these settings are gone, so add these lines to your shell configuration file, e.g. ~/.bashrc:

user@host ~> echo "export PATH=/usr/local/bin:$PATH" >> ~/.bashrc
user@host ~> echo "alias ls="ls --color"" >> ~/.bashrc

10. In order to make these settings available for all users on the system, put these last two lines in /etc/profile (check first, if PATH is already defined, it is cleaner to arrange the existing definition.

推荐阅读