Heya,
I just wanted to share this small snippet for looking up definitions of words from dict.org. It uses the dict protocol and requires curl.
define-command -override lookup_word -docstring "Lookup word under selection" -params 0..1 %{
evaluate-commands %sh{
if [ -n "$1" ]; then
WORD="$1"
else
WORD="$kak_selection"
fi # Fetch the definition and remove noise
definition=$(
curl "dict://dict.org/d:$WORD" 2>/dev/null \
| tr -d '\r' \
| grep -v '^[0-9]' \
| sed '/^\.$/d'
)
printf "info -title Definition %%{%s%%}" "$definition"
}
}
# example binding
map -docstring "Lookup word under selection" global user d ":lookup_word<ret>"
