From 7bafb5e1d4a8e6b7686f3223791f1ebecf154ea5 Mon Sep 17 00:00:00 2001 From: Ghasem Shirazi Date: Wed, 14 Apr 2021 14:10:59 -0700 Subject: [PATCH] add zsh and kubectl prompts to agnoster prompt --- dotfiles/.zshrc | 3 --- themes/agnoster.zsh-theme | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dotfiles/.zshrc b/dotfiles/.zshrc index d7732e875..085c54e0b 100644 --- a/dotfiles/.zshrc +++ b/dotfiles/.zshrc @@ -73,10 +73,7 @@ DISABLE_UNTRACKED_FILES_DIRTY="false" #plugins=(git zsh-git-prompt zsh-completions fasd systemd zsh-syntax-highlighting) plugins=(git git-extras docker docker-compose docker-machine helm fast-syntax-highlighting zsh-git-prompt) -# build up the prompt from the theme and *-prompt plugins: -PROMPT="${PROMPT} ZSH_GIT_PROMPT ZSH_KUBECTL_PROMPT" # The following lines were added by compinstall - zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate zstyle ':completion:*' max-errors 3 zstyle ':completion:*' prompt 'e%e' diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index ea2abbccb..3240232dd 100755 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -107,6 +107,14 @@ prompt_git() { #PL_BRANCH_CHAR=$'\ue0a0' #  PL_BRANCH_CHAR=$'\u2693' # anchor } + + if [[ ! -z "${ZSH_GIT_PROMPT}" ]]; then + # just use zsh-git-prompt with our segment coloring + prompt_segment yellow red + echo -n ${PL_BRANCH_CHAR} ${ZSH_GIT_PROMPT} + return + fi + local ref dirty mode repo_path if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then @@ -138,11 +146,16 @@ prompt_git() { zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c' vcs_info - echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" + echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" fi } +prompt_kubectl() { + prompt_segment magenta blue + echo -n ${ZSH_KUBECTL_PROMPT} +} + prompt_bzr() { (( $+commands[bzr] )) || return @@ -262,6 +275,7 @@ build_prompt() { prompt_context prompt_dir prompt_git + prompt_kubectl prompt_bzr prompt_hg prompt_end