Cheesy method to show currently active docker machine in PS1
#Usage: PS1='[$(__active_machine "{%s} ")\u@\h $] | |
EMOJI=🐳 | |
__active_machine() { | |
FORMAT=$1 | |
if ACTIVE=$(docker-machine active 2>/dev/null); then | |
STATE=$(docker-machine status $ACTIVE) | |
if [ "$STATE" = "Running" ]; then | |
unset STATE | |
IP=$(docker-machine ip $ACTIVE) | |
fi | |
printf "$FORMAT" "$EMOJI $ACTIVE: $STATE$IP" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
ghost commentedSep 30, 2016
This does almost as much, but without executing docker-machine (which is pretty slow to run for every prompt...). Just name your docker machines sensibly, e.g. com.domain.sub. I'm using this to essentially tell me that I'm at least referencing a docker host that isn't local, so I should pay attention (!!!).