From 0a420e70109fa2ab9448e37b32f48f79aef188fd Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 17 Feb 2021 22:29:15 +0000 Subject: [PATCH] Use BASH instead of sed(1) for user.initials I recommend looking into the BASH man page for its many awesome variable expansion features, such as substring expansion and pattern substitution. --- themes/base.theme.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index a8018381..d08ff70c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -465,7 +465,9 @@ function python_version_prompt { function git_user_info { # support two or more initials, set by 'git pair' plugin - SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%') + local raw_initials=`git config user.initials` + SCM_CURRENT_USER=${raw_initials// /+} + # if `user.initials` weren't set, attempt to extract initials from `user.name` [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" "$(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)") [[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"