Hacker News new | past | comments | ask | show | jobs | submit login

(disclaimer: this is my link/blog/software)

If that doesn't work for you, this might:

history 1 | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr

What that doesn't give you is the command tree, for example "git commit" vs "git checkout". It just does "git".

[edit, added gem link] The gem is here https://github.com/paulmars/huffshell




Generating the word tree is short and simple, though. It's also useful as a standalone Unix utility. Here's my one-minute hack:

    import sys
    import collections

    tree = lambda: collections.defaultdict(lambda: [0, tree()])

    def printtree(node, indent=0):
        padding = indent * ' '
        for word, (count, child) in node.iteritems():
            print "%s%s %d" % (padding, word, count)
            printtree(child, indent + 2)

    wordtree = tree()
    for line in sys.stdin:
        node = wordtree
        for word in line.split():
            node[word][0] += 1
            node = node[word][1]
    printtree(wordtree)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: