Merge pull request #680 from kigster/scm_user
Adding support for git user & git pair in git prompt (off by default)pull/681/merge
commit
5ec816342f
18
README.md
18
README.md
|
|
@ -166,6 +166,22 @@ also, with this flag to false, Bash-it will not show the repository as dirty whe
|
||||||
|
|
||||||
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
|
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
|
||||||
|
|
||||||
|
#### Git user
|
||||||
|
|
||||||
|
In some environments it is useful to know the value of the current git user, which is used to mark all new commits. For example, any organization that uses the practice of pair programming will typically author each commit with a [combined names of the two authors](https://github.com/pivotal/git_scripts). When another pair uses the same pairing station, the authors are changed at the beginning of the session.
|
||||||
|
|
||||||
|
To get up and running with this technique, run `gem install pivotal_git_scripts`, and then edit your `~/.pairs` file, according to the specification on the [gem's homepage](https://github.com/pivotal/git_scripts) After that you should be able to run `git pair kg as` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the `~/.pairs` file. Please see gem's documentation for more information.
|
||||||
|
|
||||||
|
To enable the display of the current pair in the prompt, you must set `SCM_GIT_SHOW_CURRENT_USER` to `true`. Once set, the `SCM_CURRENT_USER` variable will be automatically populated with the initials of the git author(s). It will also be included in the default git prompt. Even if you do not have `git pair` installed, as long as your `user.name` is set, your initials will be computed from your name, and shown in the prompt.
|
||||||
|
|
||||||
|
You can control the prefix and the suffix of this component using the two variables:
|
||||||
|
|
||||||
|
* `export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '`
|
||||||
|
|
||||||
|
And
|
||||||
|
|
||||||
|
* `export SCM_THEME_CURRENT_USER_SUFFIX=' '``
|
||||||
|
|
||||||
#### Ignore repo status
|
#### Ignore repo status
|
||||||
|
|
||||||
When working in repos with a large code base Bash-it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it.
|
When working in repos with a large code base Bash-it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it.
|
||||||
|
|
@ -184,7 +200,7 @@ $ git config --global --add bash-it.hide-status 1
|
||||||
|
|
||||||
setting this flag globally has the same effect that `SCM_CHECK=true` but only for Git repos.
|
setting this flag globally has the same effect that `SCM_CHECK=true` but only for Git repos.
|
||||||
|
|
||||||
### pass function renamed to passgen
|
### Pass function renamed to passgen
|
||||||
|
|
||||||
The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior).
|
The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ SCM_THEME_TAG_PREFIX='tag:'
|
||||||
SCM_THEME_DETACHED_PREFIX='detached:'
|
SCM_THEME_DETACHED_PREFIX='detached:'
|
||||||
SCM_THEME_BRANCH_TRACK_PREFIX=' → '
|
SCM_THEME_BRANCH_TRACK_PREFIX=' → '
|
||||||
SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ '
|
SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ '
|
||||||
|
SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '
|
||||||
|
SCM_THEME_CURRENT_USER_SUFFIX=''
|
||||||
|
|
||||||
CLOCK_CHAR='☆'
|
CLOCK_CHAR='☆'
|
||||||
THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true}
|
THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true}
|
||||||
|
|
@ -21,6 +23,7 @@ THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true}
|
||||||
SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true}
|
SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true}
|
||||||
SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
|
SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
|
||||||
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
|
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
|
||||||
|
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false}
|
||||||
|
|
||||||
SCM_GIT='git'
|
SCM_GIT='git'
|
||||||
SCM_GIT_CHAR='±'
|
SCM_GIT_CHAR='±'
|
||||||
|
|
@ -144,6 +147,8 @@ function git_prompt_vars {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)"
|
||||||
|
|
||||||
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
|
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
|
||||||
|
|
||||||
local ref=$(git symbolic-ref -q HEAD 2> /dev/null)
|
local ref=$(git symbolic-ref -q HEAD 2> /dev/null)
|
||||||
|
|
@ -332,6 +337,13 @@ function python_version_prompt {
|
||||||
echo -e "$(virtualenv_prompt)$(condaenv_prompt)$(py_interp_prompt)"
|
echo -e "$(virtualenv_prompt)$(condaenv_prompt)$(py_interp_prompt)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function git_user_info {
|
||||||
|
# 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
|
# backwards-compatibility
|
||||||
function git_prompt_info {
|
function git_prompt_info {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue