Command line history

Posted by Luke Francl
on Wednesday, April 16

Here’s mine. Try it, it’s fun.


$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
222 hg
64 rake
40 cd
23 mate
17 ssh
14 script/server
11 cap
9 script/console
8 sudo
8 ack

(hg is Mercurial. ack is a grep replacement written in Perl)

Comments

Leave a response

  1. William PietriApril 16, 2008 @ 06:13 PM

    Neat! If you wanted to avoid a scripting language, you could do it like this:

    history | cut -f3 | cut -d\ -f1 | sort | uniq -c | sort -rn

    Unfortunately, my history only lasts as long as the shell, so mine isn’t nearly as interesting.

  2. jeroenApril 16, 2008 @ 06:13 PM

    86 svn 73 cd 57 ls 48 sox 28 soxmix 27 rm 24 man 15 rake 13 mkdir 13 ./script/generate

  3. Andy LesterApril 16, 2008 @ 06:59 PM

    I’m glad you dig the ack. Could you please change the URL for ack to http://petdance.com/ack/ ? streetspam.com shouldn’t be serving that page.

    For my command list:

    http://perlbuzz.com/mechanix/2008/04/what-commands-do-you-run.html

  4. Luke FranclApril 16, 2008 @ 09:04 PM

    Andy—I’ve updated the link. Sorry, that was the first one that came up with Google.

    William—ah, nice. I love cut! Best Unix utility evar.

  5. Andrew BennettApril 16, 2008 @ 10:30 PM

    It depends which server I run it on…

    <th>development box </th> <th>production server </th> <th>production server (root) </th>
    165 git 217 sudo 106 ls
    79 cd 74 la 71 git
    61 ls 64 cd 67 la
    61 la 31 ls 48 cd
    23 shoes 30 less 39 less
    19 du 17 cat 25 cat
    15 vim 11 grep 16 vi
    14 rm 10 vim 15 vim
    9 gitk 8 tail 15 exit
    7 cap 6 git 12 hostname

    You can tell that I’ve been messing around with shoes lately and that I’m a big fan of git. You can also tell that I’ve spent the last little while configuring a lot of the server related stuff on my production server. At least, I hope my sudo numbers aren’t that high on any given day.

  6. Jon DahlApril 17, 2008 @ 09:35 AM

    Nothing too interesting here, except ffmpeg and the 29 time calls (benchmarking various ffmpeg commands).

    
    171 hg
    80 cd
    48 ls
    34 rake
    29 time
    23 mate
    23 ffmpeg
    19 script/server
    14 ssh
    10 cap
    
  7. Andy AtkinsonApril 17, 2008 @ 12:22 PM

    For the visual people, a URL (thanks Google):

    google charts link
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    
    # a dumb script - history.rb
    
    commands = {
      "hg" => 222,
      "rake" => 64,
      "cd" => 40,
      "mate" => 23,
      "ssh" => 17,
      "script/server" => 14,
      "cap" => 11,
      "script/console" => 9,
      "sudo" => 8,
      "ack" => 8
    }
    
    base_url = "http://chart.apis.google.com/chart?cht=p3&chd=t:"
    command_names = ""
    frequencies = ""
    
    commands.each do |key, value| 
      command_names == "" ? command_names << "#{key}" : command_names << "|#{key}"
      frequencies == "" ? frequencies << "#{value}" : frequencies << ",#{value}"
    end
    
    url = base_url + frequencies + "&chs=600x400&chl=" + command_names
    puts url
    
  8. Andy AtkinsonApril 17, 2008 @ 03:16 PM

    I Luke, I played around with the same thing I posted above, and redirected output to a Ruby script, that then opens the default browser with the Google Charts address.

    Check it out here

  9. brunoApril 17, 2008 @ 06:14 PM
    
    68 rake
    57 ss
    41 gst
    37 sst
    33 ssh
    30 svn
    29 git
    27 curb
    26 mate
    24 hd