From 5179d46d47519b2be56cd26f1c7de0f23c49e038 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 15 Nov 2018 13:06:10 +0100 Subject: [PATCH] Genesis --- README.md | 10 ++++++++++ _docker-enter-completion.zsh | 13 +++++++++++++ docker-enter.plugin.zsh | 10 ++++++++++ 3 files changed, 33 insertions(+) create mode 100644 README.md create mode 100644 _docker-enter-completion.zsh create mode 100644 docker-enter.plugin.zsh 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"} +} +