Explained git pair and a more reliable fallback

- Added more information to the README about the practice of using `git
  pair`, and provided instructions on installing the support.

- Write a more reliable fallback that uses `user.name` to extract user
  initials, when `user.initials` aren't set.
This commit is contained in:
Konstantin Gredeskoul
2016-03-16 20:15:20 -07:00
parent b70018e531
commit 36d994dec5
2 changed files with 10 additions and 10 deletions

View File

@@ -147,11 +147,7 @@ function git_prompt_vars {
fi
fi
if [[ "${SCM_GIT_SHOW_CURRENT_USER}" = "true" ]]; then
# support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=`git config user.initials | sed 's% %+%'`
details+="$(git_user_info)"
fi
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)"
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
@@ -342,9 +338,11 @@ function python_version_prompt {
}
function git_user_info {
if [[ -n "$SCM_CURRENT_USER" ]]; then
echo -e "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
fi
# support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%')
# 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 | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done))
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
}
# backwards-compatibility