2
I'm adding a couple of aliases to my .bashrc file for some shortcuts I use often, among which are:
alias .="cd /;ls"
alias ..="cd ../;ls"
alias cd="cd $1;ls"
alias ls="clear;pwd;ls"
The effective result being that whenever I navigate to a new directory, the window is cleared and displays the new directory and its contents at the top.
All of these aliases work except for the cd alias. I have tried multiple combinations of trying to cd in to the new directory and run ls there, but it seems like I can only either list the contents of the directory and return to the old directory, or successfully cd in to the directory but with the generated list being from the old directory.
Is there something special that needs to be done when aliasing cd (or any command with arguments) in bash? I feel like this is a relatively simple task but I'm just overlooking something with the syntax.
Just a note - FYI:
.
and..
are directory names..
== current directory..
== parent directory. Using them as aliases might cause a script somewhere heartburn. – jim mcnamara – 2011-11-09T21:32:15.107Duly noted. I'm just tinkering with bash and C++ on a spare install right now, trying to get my bearings. So I could run sudo rm -rf / and be fine :) but I'll keep that in mind for later scripts. – Zee – 2011-11-11T22:12:29.790