Sunday, May 27, 2012

We were trying to evaluate if there is any quick way to give some short cut commands in Linux shell. We wanted to have this without the need to create many script files and path jugglery.

Then we found the solution by adding command 'alias' in the local profile for the shell.

We know that the default shell configuration is located at ~/.bashrc
This file executes each time we enter the bash shell. So if you add the alias commands to this file then you can access them any time you use the shell.
It is generally  recommended to add the alias commands to the end of this file.

The syntax for the 'alias' is in the following way:

alias {shortname}='{actual command}'

Let us have a look at the use-case scenarios to shows how useful this can be:
  • Changing to a particular project directory which is long
    • eg: /home/username/Documents/githubrepos/Kicad-tools
    • This needs to be  typed all the time to reach that place
    • add the following:
alias proj='cd /home/username/Documents/githubrepos/Kicad-tools'
  • Error while typing 'cd..' instead of 'cd ..' to change to upper directory
    •  add the following:
alias cd..='cd ..'
  • Emulation of favorite dos commands
    • eg: dir, md, deltree
    • add the following:
alias dir='ls -alh'
alias md='mkdir'
alias deltree='rm -rf'
  • Shortcut commands for git operations 
    • eg: git add transformed to ga or gita
    • eg: gitk --all transformed to greal
    • add the following:
alias ga='git add'
alias greal='gitk --all &'
This list can go on of the single short commands that can be implemented in this manner.

There is a detailed tutorial available from NixCraft site.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to Boseji's Blog

Popular Post

Blogger templates

Welcome

Creation by Electronics Hobbyists from Bharat(India) to encourage & help people. This blog hosts the numerous innovations, discoveries and projects we provide.
Our Research Wing Adhar Labs
Contact Form | Email Address
We Support Open Source Hardware Definition v1.0
Creative Commons License
All works on this blog are licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at forbharat.wordpress.com and m8051.blogspot.com.

Permissions beyond the scope of this license may be available at http://forbharat.wordpress.com/permissions/.
Thank you for all your support.

© A.D.H.A.R Labs Research 2008-2013 . Powered by Blogger.

Follow by Email

Followers

PCB Unit Converter

mils
mm

- Copyright © Electronics for Bharat -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -