Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rcfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
rcfiles
Commits
93f1dbba
Commit
93f1dbba
authored
5 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Add gcloud Bash completion.
parent
9486f26d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.bash_completion.d/gcloud
+82
-0
82 additions, 0 deletions
.bash_completion.d/gcloud
with
82 additions
and
0 deletions
.bash_completion.d/gcloud
0 → 100644
+
82
−
0
View file @
93f1dbba
_python_argcomplete() {
local IFS=''
local prefix=
typeset -i n
(( lastw=${#COMP_WORDS[@]} -1))
if [[ ${COMP_WORDS[lastw]} == --*=* ]]; then
# for bash version 3.2
flag=${COMP_WORDS[lastw]%%=*}
set -- "$1" "$2" '='
elif [[ $3 == '=' ]]; then
flag=${COMP_WORDS[-3]}
fi
if [[ $3 == ssh && $2 == *@* ]] ;then
# handle ssh user@instance specially
prefix=${2%@*}@
COMP_LINE=${COMP_LINE%$2}"${2#*@}"
elif [[ $3 == '=' ]] ; then
# handle --flag=value
prefix=$flag=$2
line=${COMP_LINE%$prefix};
COMP_LINE=$line${prefix/=/ };
prefix=
fi
if [[ $2 == *,* ]]; then
# handle , separated list
prefix=${2%,*},
set -- "$1" "${2#$prefix}" "$3"
COMP_LINE==${COMP_LINE%$prefix*}$2
fi
# Treat --flag=<TAB> as --flag <TAB> to work around bash 4.x bug
if [[ ${COMP_LINE} == *= && ${COMP_WORDS[-2]} == --* ]]; then
COMP_LINE=${COMP_LINE%=}' '
fi
COMPREPLY=( $(IFS="$IFS" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" _ARGCOMPLETE=1 "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
if [[ $? != 0 ]]; then
unset COMPREPLY
return
fi
if [[ $prefix != '' ]]; then
for ((n=0; n < ${#COMPREPLY[@]}; n++)); do
COMPREPLY[$n]=$prefix${COMPREPLY[$n]}
done
fi
for ((n=0; n < ${#COMPREPLY[@]}; n++)); do
match=${COMPREPLY[$n]%' '}
if [[ $match != '' ]]; then
COMPREPLY[$n]=${match//? /' '}' '
fi
done
# if flags argument has a single completion and ends in '= ', delete ' '
if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == -* &&
${COMPREPLY[0]} == *'= ' ]]; then
COMPREPLY[0]=${COMPREPLY[0]%' '}
fi
}
complete -o nospace -F _python_argcomplete "gcloud"
_completer() {
command=$1
name=$2
eval '[[ "$'"${name}"'_COMMANDS" ]] || '"${name}"'_COMMANDS="$('"${command}"')"'
set -- $COMP_LINE
shift
while [[ $1 == -* ]]; do
shift
done
[[ $2 ]] && return
grep -q "${name}\s*$" <<< $COMP_LINE &&
eval 'COMPREPLY=($'"${name}"'_COMMANDS)' &&
return
[[ "$COMP_LINE" == *" " ]] && return
[[ $1 ]] &&
eval 'COMPREPLY=($(echo "$'"${name}"'_COMMANDS" | grep ^'"$1"'))'
}
unset bq_COMMANDS
_bq_completer() {
_completer "CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help | grep '^[^ ][^ ]* ' | sed 's/ .*//'" bq
}
complete -F _bq_completer bq
complete -o nospace -F _python_argcomplete gsutil
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment