Get the Urban Dictionary in your terminal
The Urban Dictionary website is pretty useful when one wants to know the meaning of any familiar or slang word. Users can write definitions for any words, and upvote or downvote them. Unfortunately, the website doesn’t have a public API, and I couldn’t find a command-line tool for it. So I wrote one.
Introducing ud
ud is a command-line tool which prints definitions from the Urban Dictionary website. It’s written in Ruby, and allows you to quickly search for a definition of any word.
$ ud wth
* WTH (567/126):
1) Abbreviation for "What the Hell"
2) Shortened alternative to "With"
Example:
1) WTH was that?!
2) I ate some crackers wth chicken
(…)
For common abbreviations like “wtf” or “omg”, there are dozens of definitions,
with minor differences. That’s why the script scraps only the first page of
results, and supports a few options: -n
allows you to limit the number of
definitions (e.g. -n 1
→ only one). -r
allows you to select only the
definitions which have an upvotes/downvotes ratio higher than what you want,
e.g. -r 2
will select only the definitions which have twice more upvotes than
downvotes. For your convenience, it also support the shortcut -u
which is an
alias for -r 2
. Type ud -h
for more info.
Install
That’s easy:
gem install ud
Please note that if you’re using Windows, you’ll need to install the Win32 Console ANSI gem for the colored output. Install it with:
gem install win32console
Using the UD module
The gem also provide a UD
module, which you can use to query the website in
your own Ruby code: