dic: fix edge case

This commit is contained in:
xeruf 2023-01-05 16:34:06 +01:00
parent d400aaba20
commit 1f7cd8cfa7
1 changed files with 3 additions and 2 deletions

View File

@ -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"