From ded14fce73aabfe22fe6c251b49e6e517fc9de9f Mon Sep 17 00:00:00 2001 From: Klas Mellbourn Date: Fri, 11 Aug 2017 19:50:25 +0200 Subject: [PATCH 1/2] add zsh completions --- completion/README.md | 26 +++++++++++++++++++++----- completion/_yadm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100755 completion/_yadm diff --git a/completion/README.md b/completion/README.md index 86d5960..7ec427a 100644 --- a/completion/README.md +++ b/completion/README.md @@ -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 + +``` \ No newline at end of file diff --git a/completion/_yadm b/completion/_yadm new file mode 100755 index 0000000..092f302 --- /dev/null +++ b/completion/_yadm @@ -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 "$@" \ No newline at end of file From 38318cff84cc421ab0438283722045bed1ad7bb2 Mon Sep 17 00:00:00 2001 From: Klas Mellbourn Date: Fri, 11 Aug 2017 20:09:27 +0200 Subject: [PATCH 2/2] zsh completion - improve documentation --- completion/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/completion/README.md b/completion/README.md index 7ec427a..f391e9e 100644 --- a/completion/README.md +++ b/completion/README.md @@ -22,14 +22,14 @@ Copy the completion script locally, and add this to you bashrc: ### Manual installation -Copy the completion script `_yadm` locally, and add this to you zshrc: +Copy the completion script `_yadm` locally, and add the containing folder to `$fpath` in `.zshrc`: ```shell -fpath=(/path/to/folder/containing/_yadm $fpath) +fpath=(/path/to/folder/containing_yadm $fpath) ``` ### Installation using [zplug](https://github.com/b4b4r07/zplug) -Load `_yadm` as a plugin in your `.zshrc` +Load `_yadm` as a plugin in your `.zshrc`: ```shell -zplug "TheLocehiliosan/yadm/completion/_yadm", defer:2 +zplug "TheLocehiliosan/yadm", use:"completion/_yadm", as:command, defer:2 ``` \ No newline at end of file