Skip to content

Commit

Permalink
Merge pull request yadm-dev#79 from Mellbourn/zsh-completion
Browse files Browse the repository at this point in the history
* Unified the naming between bash and zsh
* Cleaned up indentations, line endings
* Tweaked documentation
  • Loading branch information
TheLocehiliosan committed Aug 24, 2017
2 parents 5d4f3aa + 38318cf commit f0886ef
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 7 deletions.
31 changes: 24 additions & 7 deletions completion/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
# Prerequisites

**yadm** completion only works if Git completions are also enabled.

# Installation

## Homebrew
## bash completions
### Prerequisites
**yadm** completion only works if Git completions are also enabled.

### 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:

```
[ -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
### Homebrew
If using `homebrew` to install **yadm**, completions should handled automatically.

### Manual installation
Copy the completion script `yadm.zsh_completion` locally, rename it to `_yadm`, and add the containing folder to `$fpath` in `.zshrc`:
```
fpath=(/path/to/folder/containing_yadm $fpath)
autoload -U compinit
compinit
```

### Installation using [zplug](https://github.com/b4b4r07/zplug)
Load `_yadm` as a plugin in your `.zshrc`:
```
fpath=("$ZPLUG_HOME/bin" $fpath)
zplug "TheLocehiliosan/yadm", rename-to:_yadm, use:"completion/yadm.zsh_completion", as:command, defer:2
```
46 changes: 46 additions & 0 deletions completion/yadm.zsh_completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#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 "$@"

0 comments on commit f0886ef

Please sign in to comment.