Use .bashrc to activate colors and aliases in terminal

Still using that plain old black and white Terminal? how boring!

Follow these steps if you want your terminal to be more colorful!

In this tutorial you might have to use VIM to edit some files, if you don't know how to use VIM, read the basics tutorial on vim.

  1. Open Terminal.
  2. Type:
    cd
    vim .bashrc
  3. Look for (line 30):
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
  4. Uncomment the last line:
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    force_color_prompt=yes
  5. Look for these lines (line 71):
    # enable color support of ls and also add handy aliases
    if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
        eval "`dircolors -b`"
        #alias ls='ls --color=auto'
        #alias dir='ls --color=auto --format=vertical'
        #alias vdir='ls --color=auto --format=long'
  6. Uncomment the aliases you want to use (I've only uncommented the first one, for the usual listing command, but you can give a try to the other ones):
    # enable color support of ls and also add handy aliases
    if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
        eval "`dircolors -b`"
        alias ls='ls --color=auto'
        #alias dir='ls --color=auto --format=vertical'
        #alias vdir='ls --color=auto --format=long
  7. Then to activate some aliases like 'll' or 'la', find those lines (line 83):
    # some more ls aliases
    #alias ll='ls -l'
    #alias la='ls -A'
    #alias l='ls -CF'
  8. Uncomment (and modify as you like) the aliases you want, here's my changes:
    # some more ls aliases
    alias ll='ls -lh'
    #alias la='ls -A'
    #alias l='ls -CF'
  9. Save.
  10. Open a new Terminal
  11. Try some of these commands, depending on what you have activated:
    ls
    ll
    la
    dir

You can create other aliases and/or change the colors to your own favorite ones, but this will be in another tutorial!

© 2008 - 2009, Arnaud Soyez. Texts and illustrations found in this post are under the preceding copyright, unless specified otherwise.

by-sa

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: