-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash-completions
76 lines (69 loc) · 3.78 KB
/
.bash-completions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
GIT_COMPLETE_REVLIST_MAX=1500
_git_complete() {
local cur_word="${COMP_WORDS[ COMP_CWORD ]}"
local dir=$(dirname $cur_word 2> /dev/null)
local repl
case "$dir" in
(.) ;;
(/) repl=/;;
(*) repl="${dir}/";;
esac
if test "$COMP_CWORD" = 1; then
list=$( git help -a | awk '/^ /{print $1}' )
else
list=$( git for-each-ref refs --format '%(refname:short)'
command ls -F -1 "$dir" 2> /dev/null \
| sed -e "s@^@$repl@"
git rev-list --all | sed ${GIT_COMPLETE_REVLIST_MAX}q
)
fi
COMPREPLY=( $(compgen -W "${list}" -- ${cur_word}) )
}
_y_complete() {
cur_word="${COMP_WORDS[ COMP_CWORD ]}"
list=$( git for-each-ref refs --format '%(refname:short)' 2> /dev/null )
COMPREPLY=( $(compgen -W "${list}" -- ${cur_word}) )
}
_gcloud_complete() {
group_list='access-context-manager ai-platform app asset auth
bigtable builds components composer compute config
container dataflow dataproc datastore debug deployment-manager
dns domains endpoints filestore firebase functions iam
iot kms logging ml ml-engine organizations projects
pubsub redis resource-manager scheduler services source
spanner sql tasks topic'
cmd_list='
accelerator-types accessibility activate-service-account add-iam-policy-binding addresses
app app-profiles application-default arg-files asymmetric-decrypt asymmetric-sign auth
backend-buckets backend-services backups billing browse build_artifacts builds
call cancel cli-trees clusters command-conventions commitments component_manager composer
compute config-ssh configs configurations configure-docker connect connect-to-serial-port
container copy-files core create create-app-engine-task databases datafusion
dataproc datetimes decrypt delete deploy deployment_manager deployments describe
devices disable disk-types disks dns-keys domain-mappings enable encrypt environments escaping
event-types export filestore filters firewall-rules flags flags-file folders formats forwarding-rules
functions game_services gcloudignore get-ancestors get-history get-iam-policy get-server-config get-value
health-checks healthcare http-health-checks https-health-checks images import indexes install instance-configs
instance-groups instance-templates instances interactive interconnects jobs keyrings keys
language levels list list-grantable-roles list-testable-permissions list-user-verified local locations log login
logpoints logs machine-types managed-zones manifests metrics ml_engine models network-endpoint-groups networks node-pools
offline-help open-console operations os-login perimeters policies predict print-access-token print-identity-token project-configs
project-info projections proxy queues read record-sets redis regions registries reinstall remove remove-iam-policy-binding repos
repositories reservations reset-windows-password resource-descriptors resource-keys resource-policies resources restore revoke roles
routers routes rows run scp security-policies service-accounts services set set-iam-policy
shared-vpc sign-url sinks snapshots sole-tenancy source spanner speech ssh ssl ssl-certificates
ssl-certs ssl-policies start-iap-tunnel startup submit subnets subscriptions survey target-http-proxies
target-https-proxies target-instances target-pools target-ssl-proxies target-tcp-proxies target-vpn-gateways
targets test tiers topics tpus types undelete uninstall unset update url-maps users verify versions
video vision vpc-peerings vpn-tunnels workflow-templates write zones'
project_list=$(awk '{print $1}' $HOME/.config/$USER/gcloud-project-list)
case $COMP_CWORD in
1) list="$group_list";;
2) list="$cmd_list";;
*) list="$project_list";;
esac
COMPREPLY=($(compgen -W "$list" -- "${COMP_WORDS[$COMP_CWORD]}"))
}
complete -o filenames -F _git_complete g git
complete -o default -F _y_complete y
complete -o default -F _gcloud_complete gcloud