forked from yardnsm/blox-zsh-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added blocks: docker kube netns openstack
- Loading branch information
Showing
11 changed files
with
122 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# --------------------------------------------- # | ||
# | Docker block options | ||
# --------------------------------------------- # | ||
BLOX_BLOCK__DOCKER_SYMBOL="${BLOX_BLOCK__DOCKER_SYMBOL:- }" | ||
BLOX_BLOCK__DOCKER_COLOR="${BLOX_BLOCK__DOCKER_COLOR:-81}" | ||
# --------------------------------------------- # | ||
# | The block itself | ||
# --------------------------------------------- # | ||
function blox_block__docker() {( | ||
[[ ! -f /.dockerenv ]] && return | ||
docker_id=$(cat /proc/self/cgroup | grep -Po '\w{64}' | sort -u | cut -c1-12) | ||
|
||
blox_helper__build_block \ | ||
"${BLOX_BLOCK__DOCKER_COLOR}" \ | ||
"${BLOX_BLOCK__DOCKER_SYMBOL} ${docker_id}" | ||
)} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# --------------------------------------------- # | ||
# | Docker block options | ||
# --------------------------------------------- # | ||
BLOX_BLOCK__KUBE_SYMBOL="${BLOX_BLOCK__KUBE_SYMBOL:-}" | ||
BLOX_BLOCK__KUBE_COLOR="${BLOX_BLOCK__KUBE_COLOR:-111}" | ||
# --------------------------------------------- # | ||
# | The block itself | ||
# --------------------------------------------- # | ||
function blox_block__kube() {( | ||
[[ -z $KUBECONFIG ]] && return | ||
|
||
kube_context=$(cat $KUBECONFIG | grep -oPm 1 'current-context: \K.+' 2> /dev/null) | ||
|
||
if [[ -n $KUBENS ]]; then | ||
kubens=$KUBENS | ||
namespace_color=108 | ||
else | ||
kubens=$(sed -n "/- context:/,/\s*name: $context/p" $KUBECONFIG | grep -oPm 1 '\s*namespace: \K.+') | ||
namespace_color=244 | ||
fi | ||
|
||
blox_helper__build_block \ | ||
"${BLOX_BLOCK__KUBE_COLOR}" \ | ||
"${BLOX_BLOCK__KUBE_SYMBOL} ${kube_context} %F{$namespace_color}${kubens:-default}%f" | ||
)} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# --------------------------------------------- # | ||
# | NETNS block options | ||
# --------------------------------------------- # | ||
BLOX_BLOCK__NETNS_SYMBOL="${BLOX_BLOCK__NETNS_SYMBOL:- }" | ||
BLOX_BLOCK__NETNS_COLOR="${BLOX_BLOCK__NETNS_COLOR:-198}" | ||
# --------------------------------------------- # | ||
# | The block itself | ||
# --------------------------------------------- # | ||
function blox_block__netns() {( | ||
netns=$(ip netns identify $$) | ||
[[ -z $netns ]] && return | ||
|
||
blox_helper__build_block \ | ||
"${BLOX_BLOCK__NETNS_COLOR}" \ | ||
"${BLOX_BLOCK__NETNS_SYMBOL} $netns" | ||
)} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# --------------------------------------------- # | ||
# | Openstack block options | ||
# --------------------------------------------- # | ||
BLOX_BLOCK__OPENSTACK_SYMBOL="${BLOX_BLOCK__OPENSTACK_SYMBOL:-}" | ||
BLOX_BLOCK__OPENSTACK_COLOR="${BLOX_BLOCK__OPENSTACK_COLOR:-9}" | ||
|
||
# --------------------------------------------- # | ||
# | The block itself | ||
# --------------------------------------------- # | ||
function blox_block__openstack() { | ||
[[ -z $OS_PROJECT_NAME && -z $OS_TENANT_NAME ]] && return | ||
region_name=${OS_REGION_NAME:-..} | ||
|
||
display_name='' | ||
project_name=${OS_PROJECT_NAME:-$OS_TENANT_NAME} | ||
project_id=${OS_PROJECT_ID:-$OS_TENANT_ID} | ||
|
||
if [[ $project_name =~ '[0-9]+' && -n $project_id ]]; then | ||
display_name="id: ${project_id}" | ||
else | ||
display_name=$project_name | ||
fi | ||
|
||
blox_helper__build_block \ | ||
"${BLOX_BLOCK__OPENSTACK_COLOR}" \ | ||
"${BLOX_BLOCK__OPENSTACK_SYMBOL} ${region_name} %F{244}${display_name}%f" | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# --------------------------------------------- | ||
# TERRAFORM block configurations | ||
|
||
BLOX_BLOCK__TERRAFORM_COLOR="${BLOX_BLOCK__TERRAFORM_COLOR:-135}" | ||
BLOX_BLOCK__TERRAFORM_SYMBOL="${BLOX_BLOCK__TERRAFORM_SYMBOL:-}" | ||
|
||
# --------------------------------------------- | ||
|
||
function blox_block__terraform() { | ||
which terraform &> /dev/null || return | ||
|
||
if [[ -n $TF_WORKSPACE ]]; then | ||
blox_helper__build_block \ | ||
"${BLOX_BLOCK__TERRAFORM_COLOR}" \ | ||
"${BLOX_BLOCK__TERRAFORM_SYMBOL} ${TF_WORKSPACE}" | ||
fi | ||
} |
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
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