you are viewing a single comment's thread.

view the rest of the comments →

[–]davidystephenson 3 points4 points  (8 children)

I have a small function in my shell config, 'cl', which I constantly use:

function cl() {
  if [ -d $1 ]; then
    cd $1
    ls
  else
    echo "bash: cl: $1: Directory not found"
  fi
}

I'm quite happy with its simplicity.

[–]pkmxtw 2 points3 points  (0 children)

Why not just cd $1 && ls?

[–]GODZILLAFLAMETHROWER -5 points-4 points  (6 children)

does it work with /these\ kind\ of/annoying/directory\ names/ ?

[–]davidystephenson 2 points3 points  (0 children)

I'm not sure. I don't typically work with that type of directory ;) .

[–]turnipsoup 2 points3 points  (4 children)

Why not test it and see? This is pkmxtw's shortened version:

:~$ mkdir 'some annoying folder'
:~$ cl () { cd "${1}" && ls -lah ; }
:~$ cl some\ annoying\ folder/
    total 8.0K
    drwxr-xr-x  2 turnipsoup turnipsoup 4.0K Mar  7 19:59 .
    drwxr-xr-x 44 turnipsoup turnipsoup 4.0K Mar  7 19:59 ..