From 7c0de8c47ed142372e2aef4cd71277da2300b4a1 Mon Sep 17 00:00:00 2001 From: Alex Kucksdorf Date: Fri, 10 May 2019 13:29:02 +0200 Subject: [PATCH 1/2] Allow prompt symbol customization --- cobalt2.zsh-theme | 3 ++- readme.md | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cobalt2.zsh-theme b/cobalt2.zsh-theme index 28f5430..9304515 100644 --- a/cobalt2.zsh-theme +++ b/cobalt2.zsh-theme @@ -11,6 +11,7 @@ CURRENT_BG='NONE' SEGMENT_SEPARATOR='' +USER_ICON=${COBALT_2_ICON:-'✝'} # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -49,7 +50,7 @@ prompt_context() { local user=`whoami` if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then - prompt_segment black default "%(!.%{%F{yellow}%}.)✝" + prompt_segment black default "%(!.%{%F{yellow}%}.)$USER_ICON" fi } diff --git a/readme.md b/readme.md index d066cca..2b1a7c7 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,14 @@ Two things for lovers of the [Sublime Text Theme](https://github.com/wesbos/coba They work well together! You will need to install the patched powerline font as well: +## Customizing the Icon + +By default the `✝`-icon will be displayed in the prompt. However, you can customize this by exporting a symbol in `COBALT_2_ICON` like so: + +```bash +export COBALT_2_ICON=🦊 +``` + #### Step-by-step installation 1. Drop the `cobalt2.zsh-theme` file in to the `~/.oh-my-zsh/themes/` directory. 2. Open up your ZSH preferences at `~/.zshrc` and change the theme variable to `ZSH_THEME=cobalt2`. From 8cc2b70eea6d291562f1b00b6f9dd0ec259300c0 Mon Sep 17 00:00:00 2001 From: Alex Kucksdorf Date: Fri, 18 Oct 2019 15:08:49 +0200 Subject: [PATCH 2/2] Add k8s context and namespace to prompt --- cobalt2.zsh-theme | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cobalt2.zsh-theme b/cobalt2.zsh-theme index 9304515..c43c0cc 100644 --- a/cobalt2.zsh-theme +++ b/cobalt2.zsh-theme @@ -11,7 +11,7 @@ CURRENT_BG='NONE' SEGMENT_SEPARATOR='' -USER_ICON=${COBALT_2_ICON:-'✝'} +USER_ICON=${COBALT_2_ICON:-'λ'} # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -72,7 +72,14 @@ prompt_git() { # Dir: current working directory prompt_dir() { - prompt_segment blue black '%3~' + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + git_root=${$(git rev-parse --show-toplevel)##*/} + skipped_folders=${$(git rev-parse --show-cdup)%../*} + current_folder=${${$(git rev-parse --show-prefix)%/*}##*/} + prompt_segment magenta black "$git_root/$skipped_folders$current_folder" + else + prompt_segment blue black '%3~' + fi # prompt_segment blue black "…${PWD: -30}" } @@ -90,12 +97,22 @@ prompt_status() { [[ -n "$symbols" ]] && prompt_segment black default "$symbols" } + +prompt_kube() { + KUBE_SYMBOL="⎈" + # replace "-pegasus-aks" with empty string + kube_ctx=${$(kubectx -c)##*-} + kube_ns=$(kubens -c) + prompt_segment yellow black "$KUBE_SYMBOL $kube_ctx:$kube_ns" +} + ## Main prompt build_prompt() { RETVAL=$? prompt_status prompt_context prompt_dir + prompt_kube prompt_git prompt_end }