Skip to content

Instantly share code, notes, and snippets.

@shssoichiro
Created May 8, 2019 17:19
Show Gist options
  • Save shssoichiro/2ea952b27c03e4a6bb012d0522e3e11d to your computer and use it in GitHub Desktop.
Save shssoichiro/2ea952b27c03e4a6bb012d0522e3e11d to your computer and use it in GitHub Desktop.
Powerlevel9k Docker Env Component
# Make sure to place these near the top of your .zshrc. I have them after my `export PATH` and `export ZSH`.
# They must come BEFORE your POWERLEVEL9K variables.
# This will start docker-machine when your terminal opens, if it is not already started, and then default to sourcing the docker-machine environment
[[ `docker-machine status` = "Stopped" ]] && echo "\nThe Docker virtual machine is not running.\nAttemping to start the VM. This should take about a minute.\n" && docker-machine start
eval $(docker-machine env)
# This will start minikube if it is not already started
[[ `minikube status` = *"Stopped"* ]] && echo "\nThe Minikube virtual machine is not running.\nAttemping to start the VM. This should take about a minute.\n" && minikube start
# This defines the text to display in your custom terminal element
docker_env(){
if [[ $DOCKER_CERT_PATH == *minikube* ]]; then
echo "Minikube";
else
echo "Docker Machine";
fi
}
# Add `custom_docker_env` to your POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
# where you want it displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment