mirror of
https://github.com/chmln/handlr.git
synced 2024-11-27 03:13:49 +01:00
Add bash completion script
This commit is contained in:
parent
944b8cd8c1
commit
0e62d1dfa3
2 changed files with 36 additions and 2 deletions
|
@ -48,7 +48,7 @@ handlr launch x-scheme-handler/https -- https://google.ca
|
|||
- Far easier to use with simple commands like `get`, `set`, `list`
|
||||
- Can operate on extensions, **no need to look up or remember mime types**
|
||||
- useful for common tasks like setting a handler for png/docx/etc files
|
||||
- Superb autocomplete (currently just fish), including mimes, extensions, and `.desktop` files
|
||||
- Superb autocomplete (currently fish, zsh and bash), including mimes, extensions, and `.desktop` files
|
||||
- Optional json output for scripting
|
||||
- Properly supports `Terminal=true` entries
|
||||
|
||||
|
@ -109,7 +109,7 @@ cargo install handlr
|
|||
### Binaries
|
||||
|
||||
1. Download the latest [release binary](https://github.com/chmln/handlr/releases) and put it somewhere in `$PATH`
|
||||
2. Download completions:
|
||||
2. Download completions for fish:
|
||||
```sh
|
||||
curl https://raw.githubusercontent.com/chmln/handlr/master/completions/handlr.fish --create-dirs -o ~/.config/fish/completions/handlr.fish
|
||||
```
|
||||
|
|
34
completions/handlr
vendored
Normal file
34
completions/handlr
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
_handlr()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if ((cword == 1)); then
|
||||
COMPREPLY=($(compgen -W 'get help launch list open set unset' -- "$cur"))
|
||||
else
|
||||
case ${words[1]} in
|
||||
set | add)
|
||||
if ((cword == 2)); then
|
||||
COMPREPLY=($(compgen -W '$(handlr autocomplete -m)' -- "$cur"))
|
||||
elif ((cword == 3)); then
|
||||
COMPREPLY=($(compgen -W '$(handlr autocomplete -d | cut -f1)' -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
open)
|
||||
_filedir
|
||||
;;
|
||||
unset | get)
|
||||
COMPREPLY=($(compgen -W '$(handlr autocomplete -m)' -- "$cur"))
|
||||
;;
|
||||
launch)
|
||||
if ((cword == 2)); then
|
||||
COMPREPLY=($(compgen -W '$(handlr autocomplete -m)' -- "$cur"))
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _handlr handlr
|
Loading…
Reference in a new issue