Code(alpha) - Tips & Tutorials for Linux

 
  • Increase font size
  • Default font size
  • Decrease font size
Home Tutorials General / Linux Use .bashrc to activate colors and aliases in terminal

Use .bashrc to activate colors and aliases in terminal

Print

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

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

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!


Here's a screenshot demonstrating how colored file listing looks like (I also changed the background color and color themes):



Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! JoomlaVote! Google! Live! Facebook! StumbleUpon! Yahoo! Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Tuesday, 12 August 2008 23:43 )  

Add your comment

Your name:
Your email:
Subject:
Comment:

Useful Links


Newsflash

The next Ubuntu release, codenamed Intrepid Ibex, version 8.10 beta just released!

If you wish to try it out and find those hidden bugs, go ahead : http://www.ubuntu.com/testing/intrepid/beta

Note: This is a beta release. Do not install it on production machines. The final stable version will be released on October 30th, 2008.