Skip to content

Instantly share code, notes, and snippets.

@petehalverson
Last active November 12, 2016 14:30
Show Gist options
  • Select an option

  • Save petehalverson/83c4ae282244fd6aef442c31e348d29d to your computer and use it in GitHub Desktop.

Select an option

Save petehalverson/83c4ae282244fd6aef442c31e348d29d to your computer and use it in GitHub Desktop.

Revisions

  1. petehalverson revised this gist Nov 12, 2016. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions dockenv.sh
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,16 @@
    # add to .bashrc, .bash_profile, ~/.profile
    dockenv() {
    if [ $1 = 'unset' -o $1 = '-u' ]; then
    eval $(docker-machine env -u)
    else
    eval $(docker-machine env "$1")
    if ! [ $1 = 'unset' -o $1 = '-u' ]; then
    docker-machine ip $1 | tr -d '\n' | pbcopy
    command -v "docker-machine" >/dev/null 2>&1 && {
    if [ $1 = 'unset' -o $1 = '-u' ]; then
    eval $(docker-machine env -u)
    else
    eval $(docker-machine env "$1")
    if ! [ $1 = 'unset' -o $1 = '-u' ]; then
    docker-machine ip $1 | tr -d '\n' | pbcopy
    fi
    fi
    fi
    } || { echo >&2 "Error: \`docker-machine\` is required but not installed. Aborting..."; }
    }

    _dockenv() {
    local cur="${COMP_WORDS[COMP_CWORD]}"
    COMPREPLY=( $(compgen -W "$(docker-machine ls -q)" -- $cur) )
  2. petehalverson revised this gist Nov 12, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions dockenv.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@ dockenv() {
    eval $(docker-machine env -u)
    else
    eval $(docker-machine env "$1")
    if ! [ $1 = 'unset' -o $1 = '-u' ]; then
    docker-machine ip $1 | tr -d '\n' | pbcopy
    fi
    fi
    }

  3. petehalverson created this gist Nov 12, 2016.
    14 changes: 14 additions & 0 deletions dockenv.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # add to .bashrc, .bash_profile, ~/.profile
    dockenv() {
    if [ $1 = 'unset' -o $1 = '-u' ]; then
    eval $(docker-machine env -u)
    else
    eval $(docker-machine env "$1")
    fi
    }

    _dockenv() {
    local cur="${COMP_WORDS[COMP_CWORD]}"
    COMPREPLY=( $(compgen -W "$(docker-machine ls -q)" -- $cur) )
    }
    complete -o default -F _dockenv dockenv