• Tip Jar

Command Line Word Tools

It is sometimes nice to have the ability to spellcheck, or find a definition for something right on the command line. There are several tools that can help you accomplish this. For spellchecking, I use a program called hunspell.

pacaur -S hunspell hunspell-en-us-large

hunspell-en-us-large comes from the aur, so if you don’t use pacaur or some other UR helper, you wil need to download and install it.
To use it, simply enter something like the following:

echo "neibor" | hunspell -d en_US-large
error: unknown encoding UTF8: using iso88591 as fallback
error: unknown encoding UTF8: using iso88591 as fallback
error: unknown encoding UTF8: using iso88591 as fallback
error: unknown encoding UTF8: using iso88591 as fallback
Hunspell 1.3.3
& neibor 1 0: neighbor

Here we see that neighbor is mispelled, but the output is a bit ugly. Plus, who want’s to type echo “blah” and pipe it through hunspell every time. Fortunately, you can write a small script, I call it spellcheck, that cuts all the extra typing out as well as cleaning up the output. Let’s see the output from the script:

spellcheck neibor
Hunspell 1.3.3
& neibor 1 0: neighbor

Much better. So, to create this script, simply add the following to ~/bin/spellcheck if you have added that to your path, or /usr/bin/spellcheck if you prefer to have it system wide.

echo "$@" | hunspell -d en_US-large 2> /dev/null
exit 0

Save the file and remember to make it executable with chmod 755 /path/to/spellcheck
Now, you can spellcheck without seriously interupting your workflow. But, what if you come across a word and you don’t know its meaning? Never fear. There’s no need to go firing up a browser and wating for some dictionary site to load so you can wade through pages of ads just to get a one-line definition. There are two command line dictionaries I like to use. First, there is dictd:

pacman -S dictd

To use, type dict and the word you want:

dict skullduggery
1 definition found

From WordNet (r) 3.0 (2006) [wn]:

n 1: verbal misrepresentation intended to take advantage of you
in some way [syn: {trickery}, {hocus-pocus}, {slickness},
{hanky panky}, {jiggery-pokery}, {skulduggery},

You may notice the result comes from something called wordnet. Which is the other dictionary program I tend to use from the CLI. It is in the UR:

pacaur -S wordnet

Usage can vary. On some distros like ubuntu, you type out the word wordnet and the word you want, whereas in arch, you type wn and the word you want. Here’s an example of usage:

wn storm -over

Overview of noun storm

The noun storm has 3 senses (first 2 from tagged texts)

1. (8) storm, violent storm -- (a violent weather condition with winds 64-72 knots (11 on the Beaufort scale) and precipitation and thunder and lightning)
2. (3) storm, tempest -- (a violent commotion or disturbance; "the storms that had characterized their relationship had died away"; "it was only a tempest in a teapot")
3. storm -- (a direct and violent assault on a stronghold)

Overview of verb storm

The verb storm has 5 senses (first 2 from tagged texts)

1. (2) ramp, rage, storm -- (behave violently, as if in state of a great anger)
2. (1) storm, force -- (take by force; "Storm the fort")
3. storm -- (rain, hail, or snow hard and be very windy, often with thunder or lightning; "If it storms, we'll need shelter")
4. storm -- (blow hard; "It was storming all night")
5. storm, surprise -- (attack by storm; attack suddenly)

Finally, you may need to solve an anagram. Or perhapse you’re one of those people who likes playing around with words. Either way, wordplay is for you. Just install it from the UR:

pacaur -S wordplay

Of course there are lots of options so you can refine what you are lookind for, but in its simplest form, wordplay looks like this:

wordplay dragon
Wordplay Version 7.22 03-20-96, 1991 by Evans A Criswell
University of Alabama in Huntsville criswell@XX.XXX.edu

Candidate word list : no
Anagram Generation : yes
Adjacent duplicates : no
Vowel-free words OK : no

Max anagram depth : 32
Maximum word length : 128
Minimum word length : 0

Word list file : "/usr/share/wordplay/words721.txt"
String to anagram : "DRAGON"

Initializing. Please wait while words are being loaded
and unnecessary words are being filtered out ...

42 words loaded (4096 byte block). Longest kept: 6 letters.

Anagrams found:

Note I Xed out the email address. I have no clue if it is still in use, but I don’t want to send anyone spam because of an article here. Armed with these powerful word tools, you should be able to do pretty much anything you need right from the CLI without bothering to open a browser. If you have any other useful tips for word related command line apps, please leave a comment. Thanks for reading.

CLI Day 2014

CLI day has been a great holiday. I came up with it a few years ago to celebrate all the cool stuff you can do with the command line, and to hopefully get more people using it.
Last year, because of some events, I didn’t really do much for CLI Day. This year, it’s back and stronger than ever. I wanted to make some changes though, and since it’s my holiday, I figured what the heck, I may as well.
Someone suggested to me that CLI Day should be on May 31, because CLI in Roman Numerals is 151. Originally I wanted my birthday, may 29, to be CLI Day, but I realize the my birthday rocks all by itself, so the Roman Numeral thing is a great idea.
Second, I think CLI Day should be decentralized. So, if you have a blog or whatever, write about it. If you have a Identi.ca or Diaspora account, mension #CLIDay. Enjoy using the commandline, and share the love with others.
This year, for CLI Day, I would like to share a new git project with you. I have written, and am in the process of writing, some games for the command line. It’s definitely a work in progress still, but the games are a lot of fun. If you would like to play, you need bash 4.2+, rolldice, and sox.

git clone git://github.com/stormdragon2976/storm-games.git
Have fun, and enjoy CLI Day 2014!

Facebook Comes to the Command Line

I have been searching for a way to access Facebook from the command line for a while now. I don’t use Facebook all that much, I prefer Twitter, but I do have a lot of friends who use Facebook. So, I created an account, and fortunately got the Twitter application working for it before they broke (disabled) it for new users. So, to make a long story short, the only updating my Facebook account gets is usually done from my Twitter stream. Facebook, to me, just seems kind of clunky to use with a browser, that and there aren’t many accessible clients for it, so the only way to use it was with a browser. I recently got an Android phone and it adds another way to access Facebook but I really don’t use that method much either. Then, my friend Burt Henry found fbcmd. Fbcmd is a command line application written in PHP for Facebook. It is really easy to get installed. To do so, first install php by typing:
sudo apt-get install php5-CLI
Then get the fbcmd software by typing:
wget --no-check-certificate https://github.com/dtompkins/fbcmd/raw/master/fbcmd_update.php
If you are wondering about the certificate flag in the above command it is there because wget gives an error for github’s certificate. It is really the destination it claims to be. After the download completes, type the following two commands:
sudo php fbcmd_update.php
sudo php fbcmd_update.php install
Then, if you would like to verify that everything installed correctly, type:
You should get a short help message describing the procedure for granting authorization to fbcmd. if everything goes OK you can now remove the installation package using the command:
rm fbcmd_update.php
Now, to grant authorization to fbcmd type:
fbcmd go access
This will open your default browser, most likely Firefox if you are in Gnome, you will need to click allow. Next, type:
fbcmd go auth
When you click the allow button here you will be given a six6 character authorization code. I had trouble copying it to the clipboard with Orca, so you may have to memorize it long enough to type it in to terminal:
fbcmd auth XXXXXX
Where XXXXXX is your code.
Now, to see what your friends have been up to while you were busy installing this really cool program, type:
fbcmd stream
To set your status:
fbcmd status 'Thinks Thoughts of a Dragon is the greatest blog in the whole world, no, the whole universe!'
when you read through your stream you will notice each item is numbered. You can comment on the post by typing:
fbcmd comment 3 "If you need help with your diabolical world domination plans just let me know."
This will of course reply to the third post in your stream which was hopefully about diabolical world domination and not cute little bunnies, although cute world dominating bunnies might be kind of cool.
For a full list of commands and all kinds of great help visit the fbcmd wiki. You can also get help on a command by typing fbcmd help command as in:
fbcmd help status
I foresee all kinds of neat cron stuff for this application. If you think of any example feel free to share with everyone in the comments.

  • Tip Jar