Posts tagged ‘color’

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

  1. Edit your .shrc file in your home folder:
    # ee /usr/home/username/.shrc
  2. 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.

  3. Save and close the file.
  4. Logout and login and your shell should have colors when you use ls.

Using bash

  1. Edit your .shrc file in your home folder:
    # ee /usr/home/username/.shrc
  2. 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.

  3. Save and close the file.
  4. Copy the .profile file to .bash_profile.
    # cp /usr/home/username/.profile /usr/home/username/.bash_profile
  5. Edit the .bash_profile and add the following:
    # Source the .shrc
    source .shrc
  6. Logout and login and your bash shell should have colors when you use ls.

Using csh, the default shell for root

  1. 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/.cshrc

    Home folder for root:

    # ee /root/.cshrc
  2. 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 -lAG

    The first one I added, the others I only added the -G parameter to the already existing aliases for ls.

  3. Save and close the file.
  4. Logout and login and your shell should have colors when you use ls.

bash and sh for all users

  1. Edit your .shrc file in your home folder:
    # ee /usr/home/username/.shrc
  2. 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.

  3. Save and close the file.
  4. Cat this file to /etc/profile.
    # cat /usr/home/username/.shrc > /etc/profile
  5. Logout and login and your shell should have colors when you use ls.

csh for all users

  1. 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/.cshrc

    Home folder for root:

    # ee /root/.cshrc
  2. 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 -lAG

    The first one I added, the others I only added the -G parameter to the already existing aliases for ls.

  3. Save and close the file.
  4. Cat this file to /etc/csh.cshrc.
    # cat /usr/home/username/.cshrc > /etc/csh.cshrc
  5. 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.