This post is more about how to customize the output from ls rather than the specific changes that I prefer. This is achieved by my ~/bin/l script which in regular unix fashion, reuses the ls command while modifying its output.

Standard ls

This is the standard output from ls -l on my Fedora 11 distro. Specific things I dislike are:
total 28
-rw-rw-r-- 1 padraig padraig       0 2009-09-08 19:33 a_long_name_will_fit_in_
80_cols.ogg
-rw-rw-r-- 2 padraig padraig 1234567 2009-09-08 19:18 big.link
-rw-rw-r-- 2 padraig padraig 1234567 2009-09-08 19:18 big.png
-rw-rw-r-- 1 padraig padraig       0 2009-09-08 19:33 blah.jpg
crw-rw-rw- 1 root    root       1, 3 2009-09-02 21:43 device
drwxrwxr-x 2 padraig padraig    4096 2009-09-08 19:19 dir
drwxrwxr-x 2 padraig padraig    4096 2009-09-08 19:27 dir2
drwxrwxr-x 2 padraig padraig    4096 2009-09-08 19:27 dir3
-rwxrw-r-- 1 padraig padraig       0 2009-09-08 19:26 exe
prw-rw-r-- 1 padraig padraig       0 2009-09-08 19:22 fifo
-rw-rw-r-- 1 padraig padraig       0 2009-03-04 13:13 old
-rw-rwSr-- 1 padraig padraig       0 2009-09-11 08:50 setgid
drwxrwsr-x 2 padraig padraig    4096 2009-09-11 08:41 setgid_dir
-rwsrw-r-- 1 padraig padraig       0 2009-09-11 08:40 setuid
lrwxrwxrwx 1 padraig padraig       3 2009-09-08 19:21 slink1 -> dir
lrwxrwxrwx 1 padraig padraig       8 2009-09-08 22:06 slink2 -> blah.jpg
lrwxrwxrwx 1 padraig padraig       8 2009-09-10 07:19 slink3 -> dangling
drwxrwxr-t 2 padraig padraig    4096 2009-09-10 18:21 sticky_dir
drwxrwxr-T 2 padraig padraig    4096 2009-09-11 09:01 sticky_dir_2
drwxrwxrwx 2 padraig padraig    4096 2009-09-10 18:22 world_writable_dir
Note a handy way to display with a preview, ls' colour database, is:
(
 [ "$LS_COLORS" ] || eval $(dircolors)
 [ "$LS_COLORS" ] || eval $(TERM=xterm dircolors)
 printf "$LS_COLORS"
) | tr : '\n' |
sed 's/\([^=]*\)=\(.*\)/\x1b[\2m\1\x1b[0m\t\2/'
or since coreutils v9.1 (2022) you can more simply run dircolors --print-ls-colors

Customized ls

This is the output from my l script, which:
drwxrwxr-x 2 padraig     4,096 Sep  8 19:19 dir
drwxrwxr-x 2 padraig     4,096 Sep  8 19:27 dir2
drwxrwxr-x 2 padraig     4,096 Sep  8 19:27 dir3
drwxrwxr-t 2 padraig     4,096 Sep 10 18:21 sticky_dir
drwxrwxrwx 2 padraig     4,096 Sep 10 18:22 world_writable_dir
drwxrwsr-x 2 padraig     4,096 Sep 11 08:41 setgid_dir
drwxrwxr-T 2 padraig     4,096 Sep 11 09:01 sticky_dir_2
-rw-rw-r-- 1 padraig         0 Mar  4  2009 old
crw-rw-rw- 1 root         1, 3 Sep  2 21:43 device
-rw-rw-r-- 2 padraig 1,234,567 Sep  8 19:18 big.png
-rw-rw-r-- 2 padraig 1,234,567 Sep  8 19:18 big.link
lrwxrwxrwx 1 padraig         3 Sep  8 19:21 slink1 ▪▶ dir
prw-rw-r-- 1 padraig         0 Sep  8 19:22 fifo
-rwxrw-r-- 1 padraig         0 Sep  8 19:26 exe
-rw-rw-r-- 1 padraig         0 Sep  8 19:33 a_long_name_will_fit_in_80_cols.ogg
-rw-rw-r-- 1 padraig         0 Sep  8 19:33 blah.jpg
lrwxrwxrwx 1 padraig         8 Sep  8 22:06 slink2 ▪▶ blah.jpg
lrwxrwxrwx 1 padraig         8 Sep 10 07:19 slink3 ▪▶ dangling
-rwsrw-r-- 1 padraig         0 Sep 11 08:40 setuid
-rw-rwSr-- 1 padraig         0 Sep 11 08:50 setgid

Quick access

I must run ls 1000 times a day when navigating around, so making it accessible is important. Having a single letter l command that is close to the return key helps. I also have these aliases and functions defined to aid navigation:

alias ..="cd .."go to parent dir
alias ...="cd ../.."go to grandparent dir
alias -- -="cd -"go to previous dir
alias ls='ls --color=auto'turn on color
alias l.='ls -d .*'list hidden files
alias ll='ls -lhvrt'extra info compared to l
alias lld='ls -lUd */'list directories
md () { mkdir -p "$1" && cd "$1"; }go to a new dir

© Sep 18 2009