Cute..
I see from this history meme that a lot of people are still using prehistoric shells! Low numbers like 303 or even 24 total times for top execution? Now, my shell knows how to store data properly, so for example it doesn't toss away your entire session if you don't exit it cleanly, and has scaled so far with near-instant searches for a 20000+ history size.
My code:
import os,sys,sqlite3
c = sqlite3.connect(os.path.expanduser('~/.hotwire/state/history.sqlite'))
cmds = map(lambda x: x[0].split(' ', 1)[0], c.execute('SELECT cmd FROM Commands'))
stats = {}
for cmd in cmds:
count = stats.get(cmd, 0)
stats[cmd] = count+1
cmds = stats.keys()
cmds.sort(lambda a,b: cmp(stats[b],stats[a]))
for cmd in cmds:
print "%s: %s" % (cmd, stats[cmd])
Output:
cd: 2280 ls: 2003 ed: 1823 git: 1362 python: 1187 make: 817 svn: 751 sudo: 669 py: 543 cat: 442 rpm: 380 rm: 370 less: 366 cvs: 306

(Anonymous)
A technicality
App that simulates a shell, perhaps.
Also, the shell code is much shorter and suitable for command line copy and paste :)
Re: A technicality
Now, what Hotwire is not is a terminal emulator; if you want to get warped back a window to the late 1970s, Hotwire can embed VTE for that =)
(Anonymous)
Re: A technicality
The code could definitely be improved...here's a version which avoids an intermediate list (might still be a better way to do it):
import os,sys,sqlite3 c = sqlite3.connect(os.path.expanduser('~/.hotwire/state/history.sqlite')) stats = {} for result in c.execute('SELECT cmd FROM Commands'): cmd = result[0].split(' ', 1)[0] count = stats.get(cmd, 0) stats[cmd] = count+1 cmds = stats.keys() cmds.sort(lambda a,b: cmp(stats[b],stats[a])) for cmd in cmds: print "%s: %s" % (cmd, stats[cmd])(Anonymous)
prehistoric
(Anonymous)
cmds = stats.items()
cmds.sort(key=operator.itemgetter(1), reverse=True)
or if you are still on python2.3,
cmds = [(a,b) for b,a in stats.items()]
cmds.sort()
cmds.reverse()
(Anonymous)
ed: 1823
Now that is just plain sick. :)
on about: what is a shell
when it takes the meme script and makes it output your output :)