From 9a20ea9118bbcaba9cc3c7b68d3a7bd9991fea25 Mon Sep 17 00:00:00 2001 From: Robert-Jan Keizer Date: Mon, 8 Feb 2016 17:26:10 +0100 Subject: [PATCH 1/2] Added autocompletion --- autocomplete/wilfred-completion.bash | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 autocomplete/wilfred-completion.bash diff --git a/autocomplete/wilfred-completion.bash b/autocomplete/wilfred-completion.bash new file mode 100755 index 0000000..dfffc7b --- /dev/null +++ b/autocomplete/wilfred-completion.bash @@ -0,0 +1,31 @@ +#!/bin/bash + +# bash/zsh provider completion support for wilfred +# +# Usage: +# +# 1. Have wilfred installed and do `npm install -g root`. +# 2. Add the following lines to .bash_profile or .zshrc +# +# if [ -f $(npm root -g)/wilfred/autocomplete/wilfred-completion.bash ]; then +# . $(npm root -g)/wilfred/autocomplete/wilfred-completion.bash +# fi + +if [[ -n ${ZSH_VERSION-} ]]; then + autoload -U +X compinit && compinit + autoload -U +X bashcompinit && bashcompinit +fi + +_wilfred_completion() +{ + local cur=${COMP_WORDS[COMP_CWORD]} + local prev=${COMP_WORDS[COMP_CWORD-1]} + local IFS=$'\n' + + if [[ "$prev" == "wilfred" ]]; then + # Get all boilerplates using `wilfred -l` + COMPREPLY=( $(compgen -W "$(wilfred -l | awk '{print $1;}')" -- $cur) ) + fi + +} +complete -o filenames -F _wilfred_completion wilfred \ No newline at end of file From 08aa34725fc210c435df6945ec41a6eac7253166 Mon Sep 17 00:00:00 2001 From: Robert-Jan Keizer Date: Mon, 8 Feb 2016 17:31:30 +0100 Subject: [PATCH 2/2] Updated README.md with autocompletion instructions --- README.MD | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 947e346..9d59b3b 100644 --- a/README.MD +++ b/README.MD @@ -12,6 +12,16 @@ Wilfred is a simple [boilerplate](https://en.wikipedia.org/wiki/Boilerplate_code `npm install -g wilfred` +**Optional:** + +To use autocompletion on Wilfred, add the following lines to your ~/.bash_profile or ~/.zshrc. + +```bash +if [ -f $(npm root -g)/wilfred/autocomplete/wilfred-completion.bash ]; then + . $(npm root -g)/wilfred/autocomplete/wilfred-completion.bash +fi +``` + ## Usage For more information on how to use wilfred run `wilfred --help` @@ -21,11 +31,10 @@ For more information on how to use wilfred run `wilfred --help` - [x] Local folders - [x] Interactive and non-interactive mode[1](#footnote1) - [x] `.wilfredhook` for running commands after copy +- [x] Bash autocomplete - [ ] GitHub support - [ ] `.wilfredignore` for files to ignore during copy (maybe?) -- [ ] Bash autocomplete -1: If you pass in the boilerplate name as argument it will run non-interactive. If you don't it will run in interactive mode. ## Changelog