From 15dfa7fa55372f4eb7e4c9a1e72aa8de453ae290 Mon Sep 17 00:00:00 2001 From: "kujiu (@rincevent)" Date: Mon, 16 Nov 2020 22:12:19 +0100 Subject: [PATCH] Update: ZSH without Oh My ZSH --- common/.zsh/functions/git_prompt_status | 46 ++++++++++++++++++++ common/{.zshrc-private => .zsh/lib/init.zsh} | 0 2 files changed, 46 insertions(+) create mode 100644 common/.zsh/functions/git_prompt_status rename common/{.zshrc-private => .zsh/lib/init.zsh} (100%) diff --git a/common/.zsh/functions/git_prompt_status b/common/.zsh/functions/git_prompt_status new file mode 100644 index 0000000..d70fec3 --- /dev/null +++ b/common/.zsh/functions/git_prompt_status @@ -0,0 +1,46 @@ +# From https://github.com/ramen/.zsh/raw/master/functions/git_prompt_status +# +# Get the status of the working tree +INDEX=$(command git status --porcelain -b 2> /dev/null) +STATUS="" +if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" +fi +if $(echo "$INDEX" | grep '^A ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" +elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" +fi +if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" +elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" +elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" +fi +if $(echo "$INDEX" | grep '^R ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" +fi +if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" +elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" +elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" +fi +if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then + STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" +fi +if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" +fi +if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" +fi +if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" +fi +if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" +fi +echo $STATUS diff --git a/common/.zshrc-private b/common/.zsh/lib/init.zsh similarity index 100% rename from common/.zshrc-private rename to common/.zsh/lib/init.zsh