nsmartt

.bashrc

May 8th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. # Obviously this isn't my whole ~/.bashrc, but it's the part I wrote today.
  2. # I think I hate bash.
  3. # For the lazy: It's an alias for the ls command, allowing me to toggle the -A flag with -a, and applying certain arguments I want to apply each time.
  4. # It doesn't have a "clean" argument because I can't imagine I'll ever want/need one.
  5.  
  6. ls()
  7. {
  8.   local arr=""
  9.   local all=true
  10.   for val in $@
  11.   do
  12.     if [ $# -lt 1 ]; then
  13.       break
  14.     fi
  15.     if [ $val = "-a" ]; then
  16.       all=false
  17.     else
  18.       arr="$arr $val"
  19.     fi
  20.   done
  21.   local ls=$(which ls)
  22.   local cmd=""
  23.   if [ $all = false ]; then
  24.     cmd="$ls -x --group-directories-first --color=auto $arr"
  25.   else
  26.     cmd="$ls -A -x --group-directories-first --color=auto $arr"
  27.   fi
  28.   $cmd
  29. }
Advertisement
Add Comment
Please, Sign In to add comment