diff --git a/cobalt2.zsh-theme b/cobalt2.zsh-theme index 28f5430..c43c0cc 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 } @@ -71,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}" } @@ -89,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 } 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`.