Tweaking command-not-found to get quick access to tickets

Whenever someone send me a ticket number I have to do several steps:

  1. Alt+Tab to find Firefox
  2. Ctrl+T to get a new tab
  3. Type the Firefox keyword for the ticket system (I have “t” for trac)
  4. Search the ticket number

I don’t have many tickets because my code never fails (:D), but anyway it is quite boring to do all that.

So why not just press ALT+F2 and introduce the ticket number.
Turn out to be quite easy, I just modified the command-not-found script:

vi `which command-not-found`

and replace the line:

cnf = CommandNotFound(options.data_dir)


from subprocess import call
import numbers
if args[0].isdigit():
    call(["firefox", "-new-tab", "http://company.trac.url/ticket/" + args[0]])
    cnf = CommandNotFound(options.data_dir)

This just opens a new tab in Firefox with the ticket I type as a command.
This works on Firefox and Trac, but should be almost the same on any other browser or ticket system.

Now my productivity is boost ;-)

< Comment! >
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||