Skip to content

Commit 17b3b17

Browse files
Added config to display current git user.email
1 parent fa87dce commit 17b3b17

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

docs/index.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
# | GP_COLOR_GIT_BRANCH | "38;5;8" | Branch color |
2424
# | GP_COLOR_GIT_STATUS | "38;5;9" | Dirty state color |
2525
# | GP_COLOR_GIT_UNPUSHED | "38;5;11" | Unpushed state color |
26+
# | GP_COLOR_GIT_USER | "38;5;38" | Current user color |
2627
# | GP_COLOR_PWD_DARK | "1;38;5;24" | Directory color dark |
2728
# | GP_COLOR_PWD_LIGHT | "1;38;5;39" | Directory color light |
29+
# | GP_USER | (unset) | When set displays git user.email |
2830
#
2931
# ------------------------------------------------------------------------------
3032

@@ -47,9 +49,10 @@
4749
local COLOR_BRANCH=$(__gp_color "${GP_COLOR_GIT_BRANCH:-38;5;8}")
4850
local COLOR_STATUS=$(__gp_color "${GP_COLOR_GIT_STATUS:-38;5;9}")
4951
local COLOR_UNPUSHED=$(__gp_color "${GP_COLOR_GIT_UNPUSHED:-38;5;11}")
52+
local COLOR_USER=$(__gp_color "${GP_COLOR_GIT_USER:-38;5;39}")
5053
local COLOR_RESET=$(__gp_color 0)
5154

52-
local dir=${1:-.} git_status branch_info branch changes state remote ahead behind unpushed
55+
local dir=${1:-.} git_status branch_info branch changes state remote ahead behind unpushed user
5356

5457
__parse() (
5558
echo -n "$(sed -rn "$1" <<< "$branch_info")"
@@ -79,9 +82,19 @@
7982
unpushed=$(
8083
[ -n "$ahead" ] && echo -n "$ahead";
8184
[ -n "$behind" ] && echo -n "$behind";
85+
[ -z "$remote" ] && echo -n "*"
8286
)
8387

84-
printf "%s⎇ %s%s%s%s" "${COLOR_BRANCH}" "${branch}$([ -n "$remote" ] && echo -n "$remote")" "${COLOR_STATUS}${state}" "${COLOR_UNPUSHED}${unpushed}$([ -z "$remote" ] && echo -n "*")" "${COLOR_RESET}"
88+
# parse user.name
89+
if [ -n "$GP_USER" ]; then
90+
user=$(git config user.email)
91+
fi
92+
93+
branch_display="${COLOR_BRANCH}${branch}$(if [ -n "$remote" ]; then echo -n "$remote"; fi)"
94+
state_display="${COLOR_STATUS}${state}"
95+
user_display="${COLOR_USER}$(if [ -n "$GP_USER" ]; then echo -n " $user"; fi)"
96+
unpushed_display="${COLOR_UNPUSHED}${unpushed}"
97+
printf "%s%s%s%s%s" "$branch_display" "$state_display" "$unpushed_display" "$user_display" "${COLOR_RESET}"
8598
}
8699

87100
__gp_pwd() {

0 commit comments

Comments
 (0)