Last active
March 7, 2024 19:33
-
-
Save isaec/ebed80db75d826a77fd528e955db8670 to your computer and use it in GitHub Desktop.
find nearby words to your primary selection area using levenshtein, then fuzzy filter if needed, and write the choice to the clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function near | |
set selection ( | |
cat /usr/share/dict/american-english \ | |
| similar-sort -- (xclip -o) \ | |
# tiebreak=index to prefer LD sort order | |
| fzf -i +m --tiebreak=index --preview "dict {}" --preview-window="right,80%,wrap,<60(wrap,up,45%)" | |
) | |
# only run xclip if something was selected (i.e. not if fzf was exited) | |
if test "$status" -eq 0 | |
# using -loops 2 to wait until clipboard manager has grabbed | |
# using -quiet puts xclip in foreground so we wait to exit | |
echo "$selection" | xclip -r -sel clip -loops 2 -quiet | |
end | |
exit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment