Merge 5b39e35c85 into 1ffbc85a62
commit
c662c37aa7
|
|
@ -48,6 +48,7 @@ completion/available/docker.completion.bash
|
||||||
completion/available/dotnet.completion.bash
|
completion/available/dotnet.completion.bash
|
||||||
completion/available/gcloud.completion.bash
|
completion/available/gcloud.completion.bash
|
||||||
completion/available/gem.completion.bash
|
completion/available/gem.completion.bash
|
||||||
|
completion/available/getopt.completion.bash
|
||||||
completion/available/git.completion.bash
|
completion/available/git.completion.bash
|
||||||
completion/available/github-cli.completion.bash
|
completion/available/github-cli.completion.bash
|
||||||
completion/available/go.completion.bash
|
completion/available/go.completion.bash
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
function _getopt() {
|
||||||
|
local IFS=$'\n'
|
||||||
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
local prev=${COMP_WORDS[COMP_CWORD-1]:-}
|
||||||
|
|
||||||
|
local OPTIONS=('-a' '--alternative'
|
||||||
|
'-h' '--help'
|
||||||
|
'-l' '--longoptions'
|
||||||
|
'-n' '--name'
|
||||||
|
'-o' '--options'
|
||||||
|
'-q' '--quiet'
|
||||||
|
'-Q' '--quiet-output'
|
||||||
|
'-s' '--shell'
|
||||||
|
'-T' '--test'
|
||||||
|
'-u' '--unquoted'
|
||||||
|
'-V' '--version')
|
||||||
|
|
||||||
|
local SHELL_ARGS=('sh' 'bash' 'csh' 'tcsh')
|
||||||
|
|
||||||
|
case $prev in
|
||||||
|
-s | --shell)
|
||||||
|
COMPREPLY=("${SHELL_ARGS[@]}")
|
||||||
|
;;
|
||||||
|
-n | --name)
|
||||||
|
read -d '' -ra COMPREPLY < <(compgen -A function -- "$cur")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=("${OPTIONS[@]}")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _getopt -X '!&*' getopt
|
||||||
Loading…
Reference in New Issue