helm/bin/spell
Henrik Lissner b7162371a3
bin/spell: back to fzf
I no longer use skim
2020-03-29 01:44:53 -04:00

22 lines
562 B
Bash
Executable file

#!/usr/bin/env bash
# Find the correct spelling of a word. Uses (and requires) fzf to select the
# correct word. This output can be piped to something like dict to find
# definitions/synonyms.
#
# Requires: aspell, fzf
# Usage: spell mispeling
# Example: dict $(spell mispeling)
result=$(echo "$@" | aspell -a | tail -n-2)
if [[ "$result" == '*' ]]; then
echo "$@"
else
words=$(echo "$result" | sed $'s/[:,] /\\\n/g' | tail -n +2)
if (( $(wc -l <<< "$words") > 1 )) && command -v sk >/dev/null; then
fzf <<< "$words"
else
echo "$words"
fi
fi