Created
December 30, 2022 20:30
-
-
Save rimelek/823c4fb3651cfcb88fbdc0e497c6ae84 to your computer and use it in GitHub Desktop.
Custom prompt showing the current Docker context configured using environment variables. ZSH theme is "agnoster". This gist is not the whole zshrc file, only the relevant parts.
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
ZSH_THEME="agnoster" | |
plugins=(git docker docker-compose) | |
prompt_docker_host() { | |
docker_icon="\xF0\x9F\x90\xB3" | |
if [[ -n "$DOCKER_HOST" ]]; then | |
if [[ -n "$DOCKER_CONTEXT_HOST" ]] && [[ "$DOCKER_CONTEXT_HOST" == "$DOCKER_HOST" ]]; then | |
prompt_segment red default "$docker_icon $DOCKER_CONTEXT" | |
else | |
prompt_segment red default "$docker_icon $DOCKER_HOST" | |
fi | |
elif [[ -n "$DOCKER_CONTEXT" ]]; then | |
prompt_segment red default "$docker_icon $DOCKER_CONTEXT" | |
fi | |
} | |
build_prompt() { | |
RETVAL=$? | |
prompt_status | |
prompt_virtualenv | |
prompt_context | |
prompt_dir | |
prompt_git | |
prompt_docker_host | |
prompt_end | |
echo | |
echo " » " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment