How to add color to your SSH sessions in FreeBSD so files of different types have different colors when using ls?
Hey this was really easy. Really, it is just a matter of aliasing your ls
commands. However, it is only really easy if you know how to do it. When you forget, it is annoying. So here is another post to store the info I once knew but forgot and had to learn again.
Using sh
, the default shell
- Edit your .shrc file in your home folder:
# ee /usr/home/username/.shrc
- Add/Change the alias commands as follows:
alias ls=’ls -G’
alias ll=’ls -laFoG’
alias l=’ls -lG’The first one I added, the second two I only added the -G parameter to the already existing aliases for
ls
. - Save and close the file.
- Logout and login and your shell should have colors when you use
ls
.
Using bash
- Edit your .shrc file in your home folder:
# ee /usr/home/username/.shrc
- Add/Change the alias commands as follows:
alias ls=’ls -G’
alias ll=’ls -laFoG’
alias l=’ls -lG’The first one I added, the second two I only added the -G parameter to the already existing aliases for
ls
. - Save and close the file.
- Copy the .profile file to .bash_profile.
# cp /usr/home/username/.profile /usr/home/username/.bash_profile
- Edit the .bash_profile and add the following:
# Source the .shrc
source .shrc - Logout and login and your bash shell should have colors when you use
ls
.
Using csh
, the default shell for root
- As root, edit your .cshrc file in either your home folder or in the home folder for root:
Your home folder:
# ee /usr/home/username/.cshrcHome folder for root:
# ee /root/.cshrc - Add/Change the alias commands as follows: (The syntax is slightly different than for sh or bash)
alias ls ls -G
alias la ls -aG
alias lf ls -FAG
alias ll ls -lAGThe first one I added, the others I only added the -G parameter to the already existing aliases for
ls
. - Save and close the file.
- Logout and login and your shell should have colors when you use
ls
.
bash
and sh
for all users
- Edit your .shrc file in your home folder:
# ee /usr/home/username/.shrc
- Add/Change the alias commands as follows:
alias ls=’ls -G’
alias ll=’ls -laFoG’
alias l=’ls -lG’The first one I added, the second two I only added the -G parameter to the already existing aliases for
ls
. - Save and close the file.
- Cat this file to
/etc/profile
.# cat /usr/home/username/.shrc > /etc/profile - Logout and login and your shell should have colors when you use
ls
.
csh
for all users
- As root, edit your .cshrc file in either your home folder or in the home folder for root:
Your home folder:
# ee /usr/home/username/.cshrcHome folder for root:
# ee /root/.cshrc - Add/Change the alias commands as follows: (The syntax is slightly different than for sh or bash)
alias ls ls -G
alias la ls -aG
alias lf ls -FAG
alias ll ls -lAGThe first one I added, the others I only added the -G parameter to the already existing aliases for
ls
. - Save and close the file.
- Cat this file to
/etc/csh.cshrc
.# cat /usr/home/username/.cshrc > /etc/csh.cshrc - Logout and login and your shell should have colors when you use
ls
.
Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.