Bash functions to change to a directory, and immediately list its contents

Add these to your ~/.bashrc file and then load it with either . ~/.bashrc or source ~/.bashrc.

:<<COMMENT
  Change to a directory, and immediately list it's contents, (with "ls -lAF --group-directories-first"). No prompt.

  Short description: Stored in CL_DESC

  Examples
    cl ../venv
    cl ~/myproject/

  See ca
COMMENT
#CL_DESC: For "aliaf" command (with an 'f'). Must end with a newline.
CL_DESC="cl [path]: cd [path], ls\n"
cl()  {
  cd "$1"; ls -lAF --group-directories-first
}

:<<COMMENT
  Change to a directory, and immediately list it's contents, short-form (with "ls -AF --group-directories-first"). No prompt.

  Short description: Stored in CA_DESC

  Examples
    ca ../venv
    ca ~/myproject/

  See cl
COMMENT
#CA_DESC: For "aliaf" command (with an 'f'). Must end with a newline.
CA_DESC="ca [path]: cd [path], ls\n"
ca()  {
  cd "$1"; ls -AF --group-directories-first
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s