forked from yadm-dev/yadm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request yadm-dev#79 from Mellbourn/zsh-completion
* Unified the naming between bash and zsh * Cleaned up indentations, line endings * Tweaked documentation
- Loading branch information
Showing
2 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
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
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 | ||
``` |
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
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 "$@" |