From 625e0795e32907f785620413ad9e5c3c476f862d Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 29 Apr 2015 23:49:25 -0400 Subject: [PATCH] Add the new aliases and commands for docker along with the README --- modules/docker/README.md | 12 ++++++++++++ modules/docker/init.zsh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 modules/docker/init.zsh diff --git a/modules/docker/README.md b/modules/docker/README.md index 3ba80032..d1d8caf3 100644 --- a/modules/docker/README.md +++ b/modules/docker/README.md @@ -6,8 +6,20 @@ Enables boot2docker and docker support. boot2docker ----------- +Will automatically set the environment if boot2docker is running. +- `b2d` boot2docker +- `b2dstart` start docker vm, set environment +- `b2dssh` ssh to the boot2docker vm +- `b2dstop` stop the boot2docker vm +- `b2di` show boot2docker status docker ------ +- `doc` docker +- `docp` docker ps +- `docpa` docker ps -a +- `docimg` show docker images +- `docbash` launch bash in an already running container + diff --git a/modules/docker/init.zsh b/modules/docker/init.zsh new file mode 100644 index 00000000..4b54cb55 --- /dev/null +++ b/modules/docker/init.zsh @@ -0,0 +1,35 @@ +# +# Defines docker and boot2docker commands & aliases +# +# Authors: +# andrew williams (https://github.com/skarfacegc) +# + +# Only setup the boot2docker commands and aliases if we're on OSX +if [[ "$OSTYPE" == darwin* ]]; then + + # Set environment if boot2docker is already running + if [[ $(boot2docker status) == "running" ]]; then + eval $(boot2docker shellinit 2> /dev/null) + fi + + alias b2d='boot2docker' + alias b2dstart='boot2docker start &> /dev/null && eval $(boot2docker shellinit 2> /dev/null)' + alias b2dstop='boot2docker stop' + alias b2dssh='boot2docker ssh' + alias b2di='boot2docker info' + +fi + + +# Docker alases +alias doc='docker' +alias docp='docker ps' +alias docpa='docker ps -a' +alias docimg='docker images' + +docbash() { + docker exec -t -i "$1" /bin/bash +} +compdef -e 'words[1]=(docker exec); service=docker; (( CURRENT+=1 )); _docker' docbash +