.bash_completion.d/gssh
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 29 Mar 2023 23:42:06 +0300
changeset 1018 831e2c1bf980
parent 935 79dd24c983f5
permissions -rw-r--r--
Completed migration from ~/devel to ~/work.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
935
79dd24c983f5 Included --tunnel-through-iap into gssh alias.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 931
diff changeset
     1
alias gssh='gcloud compute ssh --tunnel-through-iap'
931
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
_gssh() {
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
  local cur=${COMP_WORDS[COMP_CWORD]}
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
  [[ "$cur" = -* ]] && return 0
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
  local hosts=$(gcloud compute instances list --format='value(name)')
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
  COMPREPLY=( $(compgen -W "$hosts" -- "$cur") )
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
  return 0
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
}
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
0110114150ad Added alias and completion for 'gcloud compute ssh'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
complete -F _gssh gssh