comparison .bash_prompt @ 259:09e37b590785

A couple changes since some systems use different syntax
author Steve Huston <huston@princeton.edu>
date Thu, 28 Mar 2024 20:06:31 -0400
parents d868be3816bf
children 7651a91983cd
comparison
equal deleted inserted replaced
258:7b3dbc32eac5 259:09e37b590785
40 if [ -z "$git_status" ]; then 40 if [ -z "$git_status" ]; then
41 return 1 41 return 1
42 fi 42 fi
43 43
44 # Set color based on clean/staged/dirty. 44 # Set color based on clean/staged/dirty.
45 if [[ ${git_status} =~ "working tree clean" ]]; then 45 # Some versions of git say tree, some say directory
46 green_pattern="working (tree|directory) clean"
47 if [[ ${git_status} =~ ${green_pattern} ]]; then
46 state="${GREEN}" 48 state="${GREEN}"
47 elif [[ ${git_status} =~ "Changes to be committed" ]]; then 49 elif [[ ${git_status} =~ "Changes to be committed" ]]; then
48 state="${YELLOW}" 50 state="${YELLOW}"
49 else 51 else
50 state="${LIGHT_RED}" 52 state="${LIGHT_RED}"
51 fi 53 fi
52 54
53 # Set arrow icon based on status against remote. 55 # Set arrow icon based on status against remote.
54 remote_pattern="Your branch is (.*) of" 56 remote_pattern="Your branch is (.*)"
55 if [[ ${git_status} =~ ${remote_pattern} ]]; then 57 if [[ ${git_status} =~ ${remote_pattern} ]]; then
56 if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then 58 if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
57 remote="↑" 59 remote="↑"
58 else 60 else
59 remote="↓" 61 remote="↓"