Skip to content

Instantly share code, notes, and snippets.

@denmch
Last active February 23, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denmch/f7d9b8e0f01b2ab67ec633ccc9799f9f to your computer and use it in GitHub Desktop.
Save denmch/f7d9b8e0f01b2ab67ec633ccc9799f9f to your computer and use it in GitHub Desktop.
A shell function that looks up a word via the Wordnik API, grabs each definition via json, and cats out the results with line numbers
# Define a word in the terminal via the Wordnik API with numbered output
function def() {
params="$@"
params_encoded=${params/ /%20}
curl --silent http://api.wordnik.com:80/v4/word.json/"$params_encoded"/definitions\?api_key\="$WORDNIK_KEY" \
| json --array text \
| cat -b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment