View Directory List After Entering

11th April 2008 - 1 minute read time

When navigating the file structure in Unix/Linux environments you will often find yourself typing cd to change the directory and then immediately typing ls to see the contents of the directory.

It is possible to run ls automatically every time you run cd by adding the following commands to your .bashrc file.

cd() {
 if [ -n "$1" ]; then
  builtin cd "[email protected]" && ls
  builtin cd ~ && ls



Thanks for this. I've been looking around for quite a bit trying to find this. I stumbled upon it a long time ago and lost it after a while.

Maxim (Tue, 11/24/2009 - 20:01)

Add new comment

The content of this field is kept private and will not be shown publicly.