summaryrefslogtreecommitdiff
path: root/.local/bin/fdict
blob: 8a4ed61d4bc0a492034b01dca1bb440216490541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

# fzf-dict: get word definitions using sdcv

mkdir -pv ~/.local/share/fzf
export SDCV_PAGER="less -R"

if [ "$OPENFLAG" = 0 ]; then
	sdcv --color \
		-u 'WordNet® 3.0 (En-En)' \
		-u 'American Heritage Dictionary 4th Ed. (En-En)' \
		-u 'Urban Dictionary P1 (En-En)' \
		-u 'Urban Dictionary P2 (En-En)' \
		"$@"
	sdcv -u 'Wikipedia English - Free Encyclopedia' "$@" | w3m -T text/html
	exit
fi

grep -v \' "${PREFIX:-/usr}/share/dict/words" | fzf \
	--history "$HOME/.local/share/fzf/word_history" \
	--header "Startdict Dictionary" --header-first \
	--preview='OPENFLAG=0 fzf-words {} | fold -sw "$FZF_PREVIEW_COLUMNS"' \
	--preview-window='nohidden,75%' --tiebreak=begin --print-query \
	--bind 'alt-enter:execute(OPENFLAG=0 fzf-words {q})' \
	--bind 'enter:execute(OPENFLAG=0 fzf-words {})'