Change Directories And View Files In One Custom Command

1
Change Directories And View Files In One Custom Command

We occasionally enjoy geeking out at the command line, so we love timesaving Terminal shortcuts. Reader the-soup suggests a simple tweak that combines two common commands into one: cd and ls, switching to a directory and listing its contents in one line:

Here’s a function to change directory and view files at one time, which I do often.

function cdl { cd $US1; ls;}
Just paste in .bashrc and type cdl directorytoswitchto in Terminal.

Note that this should work with any *nix command line environment, including the Terminal apps in Linux and OS X, or something like Cygwin on Windows systems.

Comments

Log in to comment on this story!