1

Possible Duplicate:
Make cd automatically ls

I think that it would be very useful to have a unix utility that combines 'cd' and 'ls' so that when you change your directory, it automatically lists the files in that directory. I have tried to do this using shell scripts, and C programs and a combination of the two, but nothing seems to work, because any 'cd' or 'chdir()' call in a shell script/ c program only changes the directory for that instance (not for the shell).

The psudocode would look like (if it was only this simple!):

cd $1
ls

If anyone has any ideas of how to implement this I would really appreciate it!

Thanks, Kevin

kguay
  • 113
  • 1
  • 4

1 Answers1

2

in your .bashrc:

cl() { cd "$1" && ls -al; }

you would use cl instead of cd to change directory and then ls -al

h3rrmiller
  • 13,235