0e99f402cd5a335042559396ae300a7668bac933

Author
Stephen Gelman <ssgelm@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(agnoster): add color config and add some git stuff (#12505)

Co-authored-by: Kilobyte22 <stiepen22@gmx.de>
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
  2index c2a5421637d0e62cc31882234bffd081223dd988..67db2cf4607e8ce9e17f3e3b2cd4a43ea3246262 100644
  3--- a/themes/agnoster.zsh-theme
  4+++ b/themes/agnoster.zsh-theme
  5@@ -39,6 +39,63 @@ case ${SOLARIZED_THEME:-dark} in
  6     *)     CURRENT_FG='black';;
  7 esac
  8 
  9+### Theme Configuration Initialization
 10+#
 11+# Override these settings in your ~/.zshrc
 12+
 13+# Current working directory
 14+: ${AGNOSTER_DIR_FG:=${CURRENT_FG}}
 15+: ${AGNOSTER_DIR_BG:=blue}
 16+
 17+# user@host
 18+: ${AGNOSTER_CONTEXT_FG:=default}
 19+: ${AGNOSTER_CONTEXT_BG:=black}
 20+
 21+# Git related
 22+: ${AGNOSTER_GIT_CLEAN_FG:=${CURRENT_FG}}
 23+: ${AGNOSTER_GIT_CLEAN_BG:=green}
 24+: ${AGNOSTER_GIT_DIRTY_FG:=black}
 25+: ${AGNOSTER_GIT_DIRTY_BG:=yellow}
 26+
 27+# Bazaar related
 28+: ${AGNOSTER_BZR_CLEAN_FG:=${CURRENT_FG}}
 29+: ${AGNOSTER_BZR_CLEAN_BG:=green}
 30+: ${AGNOSTER_BZR_DIRTY_FG:=black}
 31+: ${AGNOSTER_BZR_DIRTY_BG:=yellow}
 32+
 33+# Mercurial related
 34+: ${AGNOSTER_HG_NEWFILE_FG:=white}
 35+: ${AGNOSTER_HG_NEWFILE_BG:=red}
 36+: ${AGNOSTER_HG_CHANGED_FG:=black}
 37+: ${AGNOSTER_HG_CHANGED_BG:=yellow}
 38+: ${AGNOSTER_HG_CLEAN_FG:=${CURRENT_FG}}
 39+: ${AGNOSTER_HG_CLEAN_BG:=green}
 40+
 41+# VirtualEnv colors
 42+: ${AGNOSTER_VENV_FG:=black}
 43+: ${AGNOSTER_VENV_BG:=blue}
 44+
 45+# AWS Profile colors
 46+: ${AGNOSTER_AWS_PROD_FG:=yellow}
 47+: ${AGNOSTER_AWS_PROD_BG:=red}
 48+: ${AGNOSTER_AWS_FG:=black}
 49+: ${AGNOSTER_AWS_BG:=green}
 50+
 51+# Status symbols
 52+: ${AGNOSTER_STATUS_RETVAL_FG:=red}
 53+: ${AGNOSTER_STATUS_ROOT_FG:=yellow}
 54+: ${AGNOSTER_STATUS_JOB_FG:=cyan}
 55+: ${AGNOSTER_STATUS_BG:=black}
 56+
 57+## Non-Color settings - set to 'true' to enable
 58+# Show the actual numeric return value rather than a cross symbol.
 59+: ${AGNOSTER_STATUS_RETVAL_NUMERIC:=false}
 60+# Show git working dir in the style "/git/root   master  relative/dir" instead of "/git/root/relative/dir   master"
 61+: ${AGNOSTER_GIT_INLINE:=false}
 62+# Show the git branch status in the prompt rather than the generic branch symbol
 63+: ${AGNOSTER_GIT_BRANCH_STATUS:=true}
 64+
 65+
 66 # Special Powerline characters
 67 
 68 () {
 69@@ -83,16 +140,36 @@ prompt_end() {
 70   CURRENT_BG=''
 71 }
 72 
 73+git_toplevel() {
 74+	local repo_root=$(git rev-parse --show-toplevel)
 75+	if [[ $repo_root = '' ]]; then
 76+		# We are in a bare repo. Use git dir as root
 77+		repo_root=$(git rev-parse --git-dir)
 78+		if [[ $repo_root = '.' ]]; then
 79+			repo_root=$PWD
 80+		fi
 81+	fi
 82+	echo -n $repo_root
 83+}
 84+
 85 ### Prompt components
 86 # Each component will draw itself, and hide itself if no information needs to be shown
 87 
 88 # Context: user@hostname (who am I and where am I)
 89 prompt_context() {
 90   if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 91-    prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
 92+    prompt_segment "$AGNOSTER_CONTEXT_BG" "$AGNOSTER_CONTEXT_FG" "%(!.%{%F{$AGNOSTER_STATUS_ROOT_FG}%}.)%n@%m"
 93   fi
 94 }
 95 
 96+prompt_git_relative() {
 97+  local repo_root=$(git_toplevel)
 98+  local path_in_repo=$(pwd | sed "s/^$(echo "$repo_root" | sed 's:/:\\/:g;s/\$/\\$/g')//;s:^/::;s:/$::;")
 99+  if [[ $path_in_repo != '' ]]; then
100+    prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo"
101+  fi;
102+}
103+
104 # Git: branch/detached head, dirty status