high wisdom



Mon Feb 16 15:08:16 IST 2009

whatthefuck

I'm back from hibernation! Now that I've quit work and have a little free time, I'm back to making my life easier.

Step one, in that direction is whatthefuck. It's a wrapper around the excellent wtf utility, available via the bsdgames package in Debian (and Ubuntu). wtf is nice, but has some annoyances like :
gera@gera-laptop:~$ wtf is 3whs
Gee...  I don't know what 3whs means...
gera@gera-laptop:~$ wtf -t comp is 3whs
3WHS: three-way handshake
That's because the term exists in the 'comp' list and not the regular one. Well, chances are that if I don't know wtf it means, I wouldn't know that it's a computing term either. And what about terms which aren't in _any_ list?

Enter whatthefuck. It's a wrapper around wtf. It does the following, in order:
  • looks for the term in the default wtf list
  • if that doesn't work, looks for it in the comp list
  • failing that, gets the wikipedia page for that term
  • failing even that, launches a Google search for the term in a browser
It detects screen size and then intelligently pages the output via the default pager. For parsing wikipedia HTML, it needs html2text, and for querying the wtf lists, it needs wtf. If it doesn't find wtf, it'll just act as a lookup tool for wikipedia. It launches 'gnome-www-browser' by default, but will use the BROWSER environment variable if that's set. It also ignores the optional 'is', just like wtf:
gera@gera-laptop:~$ whatthefuck perl
perl: perl (1) - Practical Extraction and Report Language
gera@gera-laptop:~$ whatthefuck is perl
perl: perl (1) - Practical Extraction and Report Language
I alias it to 'wtf' so that I can make this completely transparent.
gera@gera-laptop:~$ alias wtf=`which whatthefuck`
gera@gera-laptop:~$ wtf is perl
perl: perl (1) - Practical Extraction and Report Language
It's a trivial script and not rocket science. But it's tremendously useful.

update (21 Feb 2009): The newer version (available at the same link) checks the uppercased term on wikipedia as well.

Posted by gera | Permanent link | File under: code, hacks | [ hide comments ]
Add comment here
name:
e-mail:
website:
spam-protection, please enter code: captcha, sorry
comment:

remember me
request e-mail if someone adds comments
Your e-Mail will not be published,
http://www.URL.com will turn to link automatically,
html is not permitted