mirror of
https://github.com/mas-cli/mas
synced 2025-02-27 04:27:11 +00:00
Merge pull request #157 from archite/simple-bash-completion
Adding simple bash completion
This commit is contained in:
commit
2937f664f8
2 changed files with 20 additions and 0 deletions
|
@ -19,6 +19,8 @@ class Mas < Formula
|
||||||
"-configuration", "Release",
|
"-configuration", "Release",
|
||||||
"SYMROOT=build"
|
"SYMROOT=build"
|
||||||
bin.install "build/mas"
|
bin.install "build/mas"
|
||||||
|
|
||||||
|
bash_completion.install "contrib/completion/mas-completion.bash" => "mas"
|
||||||
end
|
end
|
||||||
|
|
||||||
test do
|
test do
|
||||||
|
|
18
contrib/completion/mas-completion.bash
Normal file
18
contrib/completion/mas-completion.bash
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
_mas()
|
||||||
|
{
|
||||||
|
local cur prev words cword;
|
||||||
|
if declare -F _init_completions >/dev/null 2>&1; then
|
||||||
|
_init_completion
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
_get_comp_words_by_ref cur prev words cword
|
||||||
|
fi
|
||||||
|
if [[ $cword -eq 1 ]]; then
|
||||||
|
COMPREPLY=($( compgen -W "$(mas help | tail +3 | awk '{print $1}')" -- "$cur" ));
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _mas mas
|
Loading…
Add table
Reference in a new issue