Created
July 16, 2014 02:06
-
-
Save libero18/de69679943b2492f830c to your computer and use it in GitHub Desktop.
boot2dockerコマンドの手抜き補完と環境変数($DOCKER_HOST)の自動設定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## boot2docker | |
if command -v boot2docker &>/dev/null; then | |
if [ "$(boot2docker status 2> /dev/null)" = 'running' ]; then | |
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 | |
fi | |
compdef _boot2dockercmd boot2docker_wrapper | |
function _boot2dockercmd { | |
local -a cmds | |
if (( CURRENT == 2 ));then | |
cmds=('init' 'destroy' 'up' 'start' 'save' 'stop' 'download' 'pause' 'restart' 'status' 'info' 'delete' 'ssh') | |
_describe -t commands "subcommand" cmds | |
else | |
_files | |
fi | |
return 1; | |
} | |
function boot2docker_wrapper() { | |
if [ $1 = 'up' ]; then | |
shift | |
\boot2docker up $@ && export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 | |
else | |
\boot2docker $@ | |
fi | |
} | |
alias boot2docker=boot2docker_wrapper | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment