Saturday, May 16, 2009

BASH aliases

An easy way to move around using command line, without using "cd " command always.


Create ~/.bash_aliases or add to existing ~/.bash_aliases the lines below (or any long directory names which you use frequently)

alias plbin='cd /home/usr/perl/bin'
alias pllib='cd /home/usr/perl/lib'

Then you just type plbin instead of "cd /home/usr/perl/bin"
Remember to do a ". .bashrc" before you can get it to work, well also have .bash_aliases in your .bashrc

So... your ~/.bashrc should contain the following
/home/usr/.bash_aliases

and your ~/.bash_aliases should contain the lines
alias plbin='cd /home/usr/perl/bin'
alias pllib='cd /home/usr/perl/lib'

Use a '\' to escape any special characters in the directory names

No comments: