diff --git a/.config/shell/functions b/.config/shell/functions index 9f56e9d..3c99402 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -394,8 +394,9 @@ hex() { hexyl "$@" | "${PAGER:-less}"; } export DICT="$XDG_DATA_HOME/dictcc" dic() { - result=$(cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | fzf --tiebreak=chunk,length --bind='alt-bspace:clear-query' --print-query --query="$1") && - dic "$(echo "$result" | tail -1 | sed 's/\t/\n/g' | head -2 | grep --invert-match --ignore-case "$(echo "$result" | head -1)" || echo "$result" | head -1 | sed 's/ \W.*//')" + result=$(cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS#--exit-0} fzf --tiebreak=chunk,length --bind='alt-bspace:clear-query' --print-query --query="$1") && + dic "$(echo "$result" | tail -1 | sed 's/\t/\n/g' | head -2 | grep --invert-match --ignore-case "$(echo "$result" | head -1)" --max-count 1 || echo "$result" | head -1 | sed 's/ \W.*//')" + # Could be slightly improved using fzf -f to reproduce selection } #fzf --tiebreak=length --bind='alt-bspace:clear-query' alias dict="rlwrap rdictcc --directory $DICT"