2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-27 22:39:03 +00:00

Autocomplete for zsh and bash

This commit is contained in:
Aditya Hase 2018-07-11 17:57:46 +05:30
parent c7f46d5372
commit c03441b37e

View File

@ -1,30 +1,11 @@
_setup_bench_tab_completion () { _setup_bench_tab_completion () {
if [ -n "$BASH" ] ; then if [ -n "$BASH" ] ; then
_bench () { eval "$(_BENCH_COMPLETE=source bench)"
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $prev == "--site" ]]; then
COMPREPLY=( $(compgen -W "`_site_dirs`" -- $cur) )
fi
}
complete -F _bench bench
elif [ -n "$ZSH_VERSION" ]; then elif [ -n "$ZSH_VERSION" ]; then
_bench () { autoload bashcompinit
local a bashcompinit
local prev eval "$(_BENCH_COMPLETE=source bench)"
read -l a
prev=`echo $a| awk '{ print $NF }'`
if [[ $prev == "--site" ]]; then
reply=($(_site_dirs))
fi
}
compctl -K _bench bench
fi fi
} }
_site_dirs() {
ls -d sites/*/ | sed "s/sites\///g" | sed "s/\/$//g" | xargs echo
}
_setup_bench_tab_completion _setup_bench_tab_completion