2017-03-16 12:08:00 -07:00
|
|
|
#!/usr/bin/env bash
|
2017-04-24 00:06:31 -07:00
|
|
|
|
2020-03-28 22:44:53 -07:00
|
|
|
# Find the correct spelling of a word. Uses (and requires) fzf to select the
|
2017-04-24 23:31:51 -07:00
|
|
|
# correct word. This output can be piped to something like dict to find
|
|
|
|
# definitions/synonyms.
|
2017-04-24 00:06:31 -07:00
|
|
|
#
|
2020-03-28 22:44:53 -07:00
|
|
|
# Requires: aspell, fzf
|
2017-04-24 00:06:31 -07:00
|
|
|
# Usage: spell mispeling
|
|
|
|
# Example: dict $(spell mispeling)
|
|
|
|
|
|
|
|
result=$(echo "$@" | aspell -a | tail -n-2)
|
|
|
|
if [[ "$result" == '*' ]]; then
|
2017-12-05 22:39:10 -08:00
|
|
|
echo "$@"
|
2017-04-24 00:06:31 -07:00
|
|
|
else
|
2017-12-05 22:39:10 -08:00
|
|
|
words=$(echo "$result" | sed $'s/[:,] /\\\n/g' | tail -n +2)
|
2018-03-23 12:29:50 -07:00
|
|
|
if (( $(wc -l <<< "$words") > 1 )) && command -v sk >/dev/null; then
|
2020-03-28 22:44:53 -07:00
|
|
|
fzf <<< "$words"
|
2017-12-05 22:39:10 -08:00
|
|
|
else
|
|
|
|
echo "$words"
|
|
|
|
fi
|
2017-04-24 00:06:31 -07:00
|
|
|
fi
|