-
-
Save tomravalde/ea0c3ed136a62adbb4ec to your computer and use it in GitHub Desktop.
Uses www.thesaurus.com a command-line thesaurus tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
###-------------------------------------------------- | |
### T. Ravalde | |
### Last edited: 2016/05/17 | |
###-------------------------------------------------- | |
# Command line thesaurus based on code from http://www.linuxhowtos.org/Tips%20and%20Tricks/cmdline_thesaurus.htm | |
###-------------------------------------------------- | |
## SETUP AND USAGE (simple): | |
## - Download this script, and save inside the directory in which you are working | |
## - At the command line, navigate to within this directory, and type './thes <word>', where <word> is the word you want to look up. E.g. './thes differential'. | |
###-------------------------------------------------- | |
###-------------------------------------------------- | |
## SETUP AND USAGE (advanced -- can be used from any location on the computer): | |
## - Store in a location which is known by your $PATH | |
## - From any directory at the command line, type 'thes <word>', where <word> is the word you want to look up. E.g. 'thes differential'. | |
###-------------------------------------------------- | |
###-------------------------------------------------- | |
## Code | |
###-------------------------------------------------- | |
BROWSER="lynx -source" | |
WEBSITE="http://www.thesaurus.com/browse/$1" | |
HTML2TEXT="html2text -style compact" | |
if test $1; then | |
${BROWSER} ${WEBSITE} | ${HTML2TEXT} | sed -n '/Synonyms for/,/Antonyms for/p' | sed 's/star//g' | sed '1,2d' | head -n -1 | awk '{print $2}' | sed ':a;{N;s/\n/, /};ba' | |
else | |
echo "Usage: $0 word" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment