commit 5179d46d47519b2be56cd26f1c7de0f23c49e038 Author: Sebastian Mark Date: Thu Nov 15 13:06:10 2018 +0100 Genesis diff --git a/README.md b/README.md new file mode 100644 index 0000000..9465007 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# docker-enter zsh plugin + +add the alias `docker-enter` to enter an existing container. +Container names will be tab-completed. + +## Installation + +### Antigen + +`antigen bundle https://gitlab.com/smark/docker-enter.zshplugin.git` diff --git a/_docker-enter-completion.zsh b/_docker-enter-completion.zsh new file mode 100644 index 0000000..f5ec57f --- /dev/null +++ b/_docker-enter-completion.zsh @@ -0,0 +1,13 @@ +#compdef docker-enter + +_docker-enter() { + local state + _arguments -C '1: :->container' '2: :->shell' + + case $state in + (container) compadd -- $(docker ps --format '{{.Names}}');; + (shell) compadd -P /bin/ -- bash sh;; + esac +} + +_docker-enter "$@" diff --git a/docker-enter.plugin.zsh b/docker-enter.plugin.zsh new file mode 100644 index 0000000..31e0d5f --- /dev/null +++ b/docker-enter.plugin.zsh @@ -0,0 +1,10 @@ +#! /bin/zsh + +## Author: Sebastian Mark +## CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de) +## for civil use only + +docker-enter() { + docker exec -it $1 ${2:-"/bin/bash"} +} +