Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 9efd68c

Browse files
author
Ganesh Maharaj Mahalingam
committed
Script to support bash auto completion
Basic auto-completion script for ccloudvm. Signed-off-by: Ganesh Maharaj Mahalingam <[email protected]>
1 parent a4a47ac commit 9efd68c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -765,3 +765,23 @@ Removing ccloudvm service
765765
```
766766

767767
Once you run ccloudvm teardown, ccloudvm will be unusable until you run ccloudvm setup.
768+
769+
## Misc
770+
771+
### bash completion
772+
The script that might help with auto completion is located
773+
[here](./scripts/ccloudvm_bashcomplete). This can be either placed at
774+
`/etc/bash_completion.d/` of your machine or as described below.
775+
776+
Note: you will need to start a new shell to be able to make use of auto
777+
completion.
778+
779+
```
780+
$ mkdir ~/.bash_completion.d
781+
$ cp scripts/ccloudvm_bashcomplete ~/.bash_completion.d/ccloudvm
782+
$ cat << \EOF > ~/.bash_completion
783+
for file in ~/.bash_completion.d/*; do
784+
[ -f "${file}" ] && . ${file}
785+
done
786+
EOF
787+
```

scripts/ccloudvm_bashcomplete

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_ccloudvm()
2+
{
3+
local cur prev opts
4+
COMPREPLY=()
5+
cur="${COMP_WORDS[COMP_CWORD]}"
6+
prev="${COMP_WORDS[COMP_CWORD-1]}"
7+
opts="connect copy create delete help instances quit run setup start status stop teardown"
8+
9+
case "${prev}" in
10+
connect|delete|quit|run|start|status|stop)
11+
local running=$(for x in `ccloudvm instances | grep -v ^Name | awk '{print $1}'`;do echo $x; done)
12+
COMPREPLY=($(compgen -W "${running}" -- ${cur}))
13+
return 0
14+
;;
15+
*)
16+
;;
17+
esac
18+
19+
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
20+
return 0
21+
22+
}
23+
complete -F _ccloudvm ccloudvm

0 commit comments

Comments
 (0)