Created
June 5, 2020 14:47
-
-
Save soraxas/00b7e3f8342e81d2b1908e91c0eb2a9d to your computer and use it in GitHub Desktop.
completions:tldr completion for fish shell (one line) by searching within cached files
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
# This is slower, to echo everything one by one. | |
# | |
# function __fish_tldr_complete_available_pages | |
# for f in ~/.local/share/tldr/pages/**/*.md | |
# echo (string replace -r '.*/([^/]*)\.md' '$1' $f) | |
# end | |
# end | |
#complete -x -c tldr -a '(__fish_tldr_complete_available_pages)' | |
# it is faster to find everything and use a single sed command to replace it to the correct format. | |
complete -x -c tldr -a '(printf "%s\n" ~/.local/share/tldr/pages/**/*.md | sed -r "s:^.*/([^/]*)/([^/]*)\.md:\2\t\1:")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment