What's in Your Shell History?

On my Mac laptop I have these as the twenty most used commands:

overkill(shand)$ history | awk '{a[$2]++} END{for(i in a){print a[i] " " i}}' | sort -rn | head -20
847 ls
646 cd
332 svn
317 sudo
295 ping
185 port
176 rm
174 ssh
159 scp
159 ifconfig
155 vi
148 host
139 man
138 less
119 p
114 find
101 l
95 open
90 echo
86 pass

And on my Debian Linux server I have this:

maxx(root)# history | awk '{a[$2]++} END{for(i in a){print a[i] " " i}}' | sort -rn | head -20
1610 ls
1052 cd
635 less
460 grep
340 sudo
322 vi
321 l
311 rcsedit
216 for
201 host
195 cat
166 mkroot
154 tail
154 mv
152 rm
139 svn
127 cp
123 apache2ctl
118 find
115 apt-cache

Most of this is pretty straight forward the only interesting ones are:

  • "port" is the command line utility from MacPorts for managing packages
  • "l" is the standard "ls -l" alias which everybody has:

    l() { ls -l $* | more; }
    
  • "p" is a slightly fancy alias which basically does "ps -efww | grep" but with some cross platform smarts:

    p() { 
        if [ $LINUX ]; then 
            OPTIONS="-efww"; 
        elif [ $IRIX ] ; then
            OPTIONS="-ef";
        elif [ $DARWIN ]; then
            OPTIONS="-Ajww";
        fi
        if [ ! $1 ]; then
            ps ${OPTIONS} | more
        else
            ps ${OPTIONS} | grep -i $1 | more
        fi;
    }
    
  • "rcsedit" is the standard sysadmin wrapper script for making editing files with RCS easy.

  • "mkroot" is what I use to become root and keep my personalised environment (because modifying root's environment is a bad thing):

    alias mkroot='sudo bash --rcfile ~/.bash_profile'
    
  • "pass" is a script I use for managing my passwords in a GPG encrypted file

Though it doesn't make this list, "spex" is another great alias which I use for remembering obscure and useful command lines.

spex () { curl --silent -A Firefox "http://www.spack.org/wiki/CommandLine?action=raw" | grep :: | grep --color -i $1; }