Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker_context segment #1641

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/p10k-classic.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
docker_context # current docker context (https://docs.docker.com/engine/context/working-with-contexts/)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
# terraform_version # terraform version (https://www.terraform.io)
Expand Down Expand Up @@ -1212,6 +1213,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'

#############[ docker_context: current docker context (https://docs.docker.com/engine/context/working-with-contexts/) ]#############
# Show docker context only when the command you are typing invokes one of these (pipe-separated) tools.
# Comment the next line to always show docker context.
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_ON_COMMAND='docker'
# Don't show docker context if it's literally "default".
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT=false

#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext.
Expand Down
8 changes: 8 additions & 0 deletions config/p10k-lean-8colors.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
docker_context # current docker context (https://docs.docker.com/engine/context/working-with-contexts/)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
# terraform_version # terraform version (https://www.terraform.io)
Expand Down Expand Up @@ -1154,6 +1155,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐'

#############[ docker_context: current docker context (https://docs.docker.com/engine/context/working-with-contexts/) ]#############
# Show docker context only when the command you are typing invokes one of these (pipe-separated) tools.
# Comment the next line to always show docker context.
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_ON_COMMAND='docker'
# Don't show docker context if it's literally "default".
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT=false

#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext.
Expand Down
8 changes: 8 additions & 0 deletions config/p10k-lean.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
docker_context # current docker context (https://docs.docker.com/engine/context/working-with-contexts/)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
# terraform_version # terraform version (https://www.terraform.io)
Expand Down Expand Up @@ -1150,6 +1151,13 @@
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐'

#############[ docker_context: current docker context (https://docs.docker.com/engine/context/working-with-contexts/) ]#############
# Show docker context only when the command you are typing invokes one of these (pipe-separated) tools.
# Comment the next line to always show docker context.
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_ON_COMMAND='docker'
# Don't show docker context if it's literally "default".
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT=false

#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext.
Expand Down
8 changes: 8 additions & 0 deletions config/p10k-rainbow.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
docker_context # current docker context (https://docs.docker.com/engine/context/working-with-contexts/)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
# terraform_version # terraform version (https://www.terraform.io)
Expand Down Expand Up @@ -1283,6 +1284,13 @@
################[ terraform_version: It shows active terraform version (https://www.terraform.io) ]#################
typeset -g POWERLEVEL9K_TERRAFORM_VERSION_SHOW_ON_COMMAND='terraform|tf'

#############[ docker_context: current docker context (https://docs.docker.com/engine/context/working-with-contexts/) ]#############
# Show docker context only when the command you are typing invokes one of these (pipe-separated) tools.
# Comment the next line to always show docker context.
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_ON_COMMAND='docker'
# Don't show docker context if it's literally "default".
typeset -g POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT=false

#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext.
Expand Down
6 changes: 6 additions & 0 deletions internal/icons.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function _p9k_init_icons() {
JULIA_ICON 'jl'
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' # ⬢
DOCKER_ICON '\U1F433' # 🐳
)
;;
'awesome-fontconfig')
Expand Down Expand Up @@ -278,6 +279,7 @@ function _p9k_init_icons() {
JULIA_ICON 'jl'
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' # ⬢
DOCKER_ICON '\U1F433' # 🐳
)
;;
'awesome-mapped-fontconfig')
Expand Down Expand Up @@ -412,6 +414,7 @@ function _p9k_init_icons() {
JULIA_ICON 'jl'
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' # ⬢
DOCKER_ICON '\U1F433' # 🐳
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
Expand Down Expand Up @@ -544,6 +547,7 @@ function _p9k_init_icons() {
JULIA_ICON '\uE624' # 
SCALA_ICON '\uE737' # 
TOOLBOX_ICON '\uE20F'$s # 
DOCKER_ICON '\U1F433' # 🐳
)
;;
ascii)
Expand Down Expand Up @@ -673,6 +677,7 @@ function _p9k_init_icons() {
JULIA_ICON 'jl'
SCALA_ICON 'scala'
TOOLBOX_ICON 'toolbox'
DOCKER_ICON 'docker'
)
;;
*)
Expand Down Expand Up @@ -804,6 +809,7 @@ function _p9k_init_icons() {
JULIA_ICON 'jl'
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' # ⬢
DOCKER_ICON '\U1F433' # 🐳
)
;;
esac
Expand Down
22 changes: 22 additions & 0 deletions internal/p10k.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,27 @@ prompt_dir() {

instant_prompt_dir() { prompt_dir; }

################################################################
# Docker context
prompt_docker_context() {
local ctx=${DOCKER_CONTEXT:-default}
if [[ -z ${DOCKER_CONTEXT:-} ]]; then
if (( $+commands[jq] )); then
local cfg=${DOCKER_CONFIG:-~/.docker/config.json}
ctx="$(jq -e -r '.currentContext' $cfg 2>/dev/null)" || ctx=default
else;
ctx=$(docker context show)
fi
fi
[[ -z $ctx || $ctx == default && $_POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT == 0 ]] && return
_p9k_prompt_segment "$0" "$_p9k_color1" "deepskyblue1" 'DOCKER_ICON' 0 '' "$ctx"
}

_p9k_prompt_docker_context_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[docker]'
}


################################################################
# Docker machine
prompt_docker_machine() {
Expand Down Expand Up @@ -7495,6 +7516,7 @@ _p9k_init_params() {
_p9k_declare -a POWERLEVEL9K_KUBECONTEXT_CLASSES --
_p9k_declare -a POWERLEVEL9K_AWS_CLASSES --
_p9k_declare -a POWERLEVEL9K_AZURE_CLASSES --
_p9k_declare -b POWERLEVEL9K_DOCKER_CONTEXT_SHOW_DEFAULT 0
_p9k_declare -a POWERLEVEL9K_TERRAFORM_CLASSES --
_p9k_declare -b POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT 0
_p9k_declare -a POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES -- 'service_account:*' SERVICE_ACCOUNT
Expand Down