Skip to content

Instantly share code, notes, and snippets.

@extratone
Forked from denmch/wordnik-shell-function.sh
Created March 6, 2026 13:54
Show Gist options
  • Select an option

  • Save extratone/b8f07e8727ef76ab4d0a76716014bbac to your computer and use it in GitHub Desktop.

Select an option

Save extratone/b8f07e8727ef76ab4d0a76716014bbac 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