Last Updated: September 30, 2021
·
2.832K
· dotcode

Compress the cd, ls -la series of commands

Don't bother typing "cd foo; ls -la" - instead add this to your startup script of preference and just do it in one:

function cl () {
   if [ $# = 0 ]; then
      cd && ls -la
   else
      cd "$*" && ls -la
   fi
}

Usage: cl [path]

3 Responses
Add your response

For me it's very annoying.
Whats happens when you go to directory with 10k files? ;)

over 1 year ago ·

That and the following are my favorite bash functions:

mcd() { mkdir -p "$@" && cd $_; }

This creates a new directory (if it does not exist) and cd's to it.

over 1 year ago ·

I have configured ZSH like this: 'foo; l', which means 'cd foo; ls -l'

over 1 year ago ·