Skip to content

Instantly share code, notes, and snippets.

@jsocol
Created May 12, 2013 15:02
Show Gist options
  • Select an option

  • Save jsocol/5563847 to your computer and use it in GitHub Desktop.

Select an option

Save jsocol/5563847 to your computer and use it in GitHub Desktop.
Change directories and list contents.
# I found myself doing this a lot: cd path/<enter>ls<enter> and thought "that's silly".
# Put this in your .bashrc or another file that is sourced (*not* executed) into your
# shell environment. Then you'll have the "lcd" command available.
# Change directory and list contents.
lcd () {
if [ $# -eq 1 ]; then
cd $1 && ls
elif [ $# -eq 2 ]; then
cd $2 && ls $1
else
echo "USAGE: $0 [options] path"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment