add zsh completions

This commit is contained in:
Klas Mellbourn 2017-08-11 19:50:25 +02:00
parent 4b5b6c44d3
commit ded14fce73
2 changed files with 65 additions and 5 deletions

View File

@ -1,10 +1,11 @@
# Prerequisites
# Installation
## bash completions
### Prerequisites
**yadm** completion only works if Git completions are also enabled.
# Installation
## Homebrew
### Homebrew
If using `homebrew` to install **yadm**, completions should automatically be handled if you also install `brew install bash-completion`. This might require you to include the main completion script in your own bashrc file like this:
@ -12,8 +13,23 @@ If using `homebrew` to install **yadm**, completions should automatically be han
[ -f /usr/local/etc/bash_completion ] && source /usr/local/etc/bash_completion
```
## Manual installation
### Manual installation
Copy the completion script locally, and add this to you bashrc:
```
[ -f /full/path/to/yadm.bash_completion ] && source /full/path/to/yadm.bash_completion
```
## zsh completions
### Manual installation
Copy the completion script `_yadm` locally, and add this to you zshrc:
```shell
fpath=(/path/to/folder/containing/_yadm $fpath)
```
### Installation using [zplug](https://github.com/b4b4r07/zplug)
Load `_yadm` as a plugin in your `.zshrc`
```shell
zplug "TheLocehiliosan/yadm/completion/_yadm", defer:2
```

44
completion/_yadm Executable file
View File

@ -0,0 +1,44 @@
#compdef yadm
_yadm(){
local -a _1st_arguments
_1st_arguments=('help:Display yadm command help'
'init:Initialize an empty repository'
'config:Configure a setting'
'list:List tracked files'
'alt:Create links for alternates'
'bootstrap:Execute $HOME/.yadm/bootstrap'
'encrypt:Encrypt files'
'decrypt:Decrypt files'
'perms:Fix perms for private files'
'add:git add'
'push:git push'
'pull:git pull'
'diff:git diff'
'checkout:git checkout'
'co:git co'
'commit:git commit'
'ci:git ci'
'status:git status'
'st:git st'
'reset:git reset'
'log:git log')
local context state line expl
local -A opt_args
_arguments '*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "yadm commands" _1st_arguments -V1
return
fi
case "$words[1]" in
*)
_arguments \
':filenames:_files'
;;
esac
}
_yadm "$@"