From 6a4766869078f53e0f297a8f6fb0c91f14052b4a Mon Sep 17 00:00:00 2001 From: Shawn Sorichetti Date: Mon, 5 Mar 2012 14:25:20 -0500 Subject: [PATCH] The original code would only match if the first line matched the conditions. By adding the * after the # it now searches throughout the string. The only issues could be when filenames have spaces in them, specifically when the last letter of one section matches and then there's a space, or multiple spaces. --- lib/git.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 9819f7faa..c5432cdb9 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -34,30 +34,30 @@ function git_prompt_long_sha() { git_prompt_status() { INDEX=$(git status --porcelain 2> /dev/null) STATUS="" - if [ "${INDEX#?? }" != "$INDEX" ]; then + if [ "${INDEX#*?? }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi - if [ "${INDEX#A }" != "$INDEX" ]; then + if [ "${INDEX#*A }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif [ "${INDEX#M }" != "$INDEX" ]; then + elif [ "${INDEX#*M }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" fi - if [ "${INDEX# M }" != "$INDEX" ]; then + if [ "${INDEX#* M }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif [ "${INDEX#AM }" != "$INDEX" ]; then + elif [ "${INDEX#*AM }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif [ "${INDEX# T }" != "$INDEX" ]; then + elif [ "${INDEX#* T }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" fi - if [ "${INDEX#R }" != "$INDEX" ]; then + if [ "${INDEX#*R }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" fi - if [ "${INDEX# D }" != "$INDEX" ]; then + if [ "${INDEX#* D }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - elif [ "${INDEX#AD }" != "$INDEX" ]; then + elif [ "${INDEX#*AD }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if [ "${INDEX#UU }" != "$INDEX" ]; then + if [ "${INDEX#*UU }" != "$INDEX" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi echo $STATUS