mirror of
https://github.com/vimagick/dockerfiles
synced 2024-06-20 13:58:42 +00:00
auto-completion for docker-exec
This commit is contained in:
parent
0c0bdcc0f4
commit
965e160443
28
README.md
28
README.md
@ -102,3 +102,31 @@ dockerfiles
|
||||
- [x] standalone-firefox
|
||||
- [x] tutum/builder
|
||||
|
||||
## auto-completion
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
#
|
||||
# handy auto-completion for docker-exec
|
||||
#
|
||||
|
||||
enter() {
|
||||
local name=${1:?}
|
||||
docker exec -it $name sh -c 'exec $(command -v bash || command -v sh)'
|
||||
}
|
||||
|
||||
__enter() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
for cid in $(docker ps -q)
|
||||
do
|
||||
local name=$(docker inspect -f '{{.Name}}' $cid)
|
||||
name=${name#/}
|
||||
if [[ $name = $cur* ]]
|
||||
then
|
||||
COMPREPLY+=("$name")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __enter enter
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user