From 89a259549554009e62dc0177777f8084fa1db8a7 Mon Sep 17 00:00:00 2001 From: Natalie Pendragon Date: Tue, 11 Dec 2018 06:10:49 -0500 Subject: [PATCH] Add support for Fish-based autocompletion (#71) --- README.md | 7 +++---- fish_tealdeer | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 fish_tealdeer diff --git a/README.md b/README.md index 2eee710..6c4fa13 100644 --- a/README.md +++ b/README.md @@ -178,11 +178,10 @@ Example customization: Screenshot of customized version -## Bash Autocompletion - -To get bash autocompletion, simply rename the file `bash_tealdeer` to `tldr` -and copy it to `/usr/share/bash-completion/completions/tldr`. +## Autocompletion +- *Bash*: copy `bash_tealdeer` to `/usr/share/bash-completion/completions/tldr` +- *Fish*: copy `fish_tealdeer` to `~/.config/fish/completions/tldr.fish` ## Development diff --git a/fish_tealdeer b/fish_tealdeer new file mode 100644 index 0000000..9276e9a --- /dev/null +++ b/fish_tealdeer @@ -0,0 +1,21 @@ +# +# Completions for the tealdeer implementation of tldr +# https://github.com/dbrgn/tealdeer/ +# + +complete -c tldr -s h -l help -d 'Print the help message.' -f +complete -c tldr -s v -l version -d 'Show version information.' -f +complete -c tldr -s l -l list -d 'List all commands in the cache.' -f +complete -c tldr -s f -l render -d 'Render a specific markdown file.' -r +complete -c tldr -s o -l os -d 'Override the operating system.' -xa 'linux osx sunos other' +complete -c tldr -s u -l update -d 'Update the local cache.' -f +complete -c tldr -s c -l clear-cache -d 'Clear the local cache.' -f +complete -c tldr -s q -l quiet -d 'Suppress informational messages.' -f +complete -c tldr -l config-path -d 'Show config file path.' -f +complete -c tldr -l seed-config -d 'Create a basic config.' -f + +function __tealdeer_entries + tldr --list | sed -e 's/, /\n/g' +end + +complete -f -c tldr -a '(__tealdeer_entries)'