akoimeexx

Bash ll function, updated

Jul 1st, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Updated to fix a glitch that caused the directory listing location to output multiple
  2. # lines when viewing a directory with spaces in it.
  3.  
  4. # Custom directory listing function for great justice and my own amusement.
  5. function ll () {
  6.     # Suss out the directory we're trying to list
  7.     if [ -d ${@:-1} ]
  8.         then location=${@:-1}
  9.         else location=`pwd`
  10.     fi
  11.     # Put together our directory listing, with custom headers.
  12.     # Include additional arguments passed in from the function call.
  13.     # Pipe the output through more
  14.     {
  15.         printf '\x1b\x5b34m<index \x1b\x5b32mlocation\x1b\x5b35m=\x1b\x5b33m\"%s\"\x1b\x5b34m>\x1b\x5b00m\n' "$location" &&
  16.         ls -FGhlpv --group-directories-first --color=always $@ &&
  17.         printf '\x1b\x5b34m</index>\x1b\x5b00m\n';
  18.     } |more
  19. }
Advertisement
Add Comment
Please, Sign In to add comment