cd, ls, cd, ls, cd, ls
During one of his presentation, I thought I had noticed that Damian Conway had his shell automatically list the contents of a directory after changing to it. A pretty good idea, as my history file confirms that I follow a cd with an ls more than 50% of the time.
The problem? In both bash & zsh, this does what you expect but not what you want:
function cd() { cd $1; ls; }
Instead, you have to use builtin so that the shell knows if you mean the user-defined or builtin version of cd:
function cd() { builtin cd $1; ls; }
If you want extra style points in zsh, you can define the chpwd function:
function chpwd() { ls; }

February 21st, 2005 at 6:21 pm
I wouldn’t like the cd ls combination.
Maybe if it were ls -lrt in some directories and ls -l in others
February 22nd, 2005 at 12:54 am
I GPL’ed the above code, so feel free to modify it.
February 22nd, 2005 at 11:39 am
If this “cd; ls” innovation shows up in SCO Unix, we are fucked.
February 22nd, 2005 at 4:31 pm
dork.
February 22nd, 2005 at 9:54 pm
Khayman’s just bitter I didn’t submit this for his QA approval.