add bash completion
This commit is contained in:
parent
2d9b0f77b3
commit
cbf64a2e14
2 changed files with 17 additions and 0 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
src = self;
|
src = self;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
install -m 755 -D gra $out/bin/gra
|
install -m 755 -D gra $out/bin/gra
|
||||||
|
install -m 644 -D gra_completion.bash $out/share/bash-completion/completions/gra
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
default = self.packages.${system}.gra;
|
default = self.packages.${system}.gra;
|
||||||
|
|
|
||||||
16
gra_completion.bash
Normal file
16
gra_completion.bash
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
function _gra_completion {
|
||||||
|
|
||||||
|
_args="-h --help"
|
||||||
|
|
||||||
|
# Add config values to completion
|
||||||
|
if [ "${#COMP_WORDS[@]}" -lt 3 ] && [ -f ~/.config/gra.config ]; then
|
||||||
|
readarray -t lines < ~/.config/gra.config
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
[[ "$line" =~ ^(.*)= ]] && _args="$_args ${BASH_REMATCH[1]}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPREPLY=($(compgen -W "$_args" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _gra_completion gra
|
||||||
Loading…
Add table
Add a link
Reference in a new issue