commit
c3572e21fe
17
README.md
17
README.md
|
|
@ -98,6 +98,23 @@ Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it:
|
|||
|
||||
* `export SCM_GIT_SHOW_DETAILS=false`
|
||||
|
||||
### Git remotes and remote branches
|
||||
In some git workflows you must work with various remotes, for this reason, Bash it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch.
|
||||
|
||||
You can control this feature with the flag `SCM_GIT_SHOW_REMOTE_INFO` as follows:
|
||||
|
||||
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo:
|
||||
|
||||
* `export SCM_GIT_SHOW_REMOTE_INFO=auto`
|
||||
|
||||
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'true' to always activate the feature:
|
||||
|
||||
* `export SCM_GIT_SHOW_REMOTE_INFO=true`
|
||||
|
||||
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**:
|
||||
|
||||
* `export SCM_GIT_SHOW_REMOTE_INFO=false`
|
||||
|
||||
#### 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).
|
||||
|
|
|
|||
|
|
@ -10,17 +10,20 @@ SCM_THEME_PROMPT_PREFIX=' |'
|
|||
SCM_THEME_PROMPT_SUFFIX='|'
|
||||
SCM_THEME_BRANCH_PREFIX=''
|
||||
SCM_THEME_TAG_PREFIX='tag:'
|
||||
SCM_THEME_COMMIT_PREFIX='commit:'
|
||||
SCM_THEME_REMOTE_PREFIX=''
|
||||
SCM_THEME_DETACHED_PREFIX='detached:'
|
||||
SCM_THEME_BRANCH_TRACK_PREFIX=' → '
|
||||
SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ '
|
||||
|
||||
CLOCK_CHAR='☆'
|
||||
THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true}
|
||||
THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true}
|
||||
|
||||
SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true}
|
||||
SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
|
||||
|
||||
SCM_GIT='git'
|
||||
SCM_GIT_CHAR='±'
|
||||
SCM_GIT_DETACHED_CHAR='⌿'
|
||||
SCM_GIT_AHEAD_CHAR="↑"
|
||||
SCM_GIT_BEHIND_CHAR="↓"
|
||||
SCM_GIT_UNTRACKED_CHAR="?:"
|
||||
|
|
@ -107,23 +110,50 @@ function git_prompt_vars {
|
|||
fi
|
||||
fi
|
||||
|
||||
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
|
||||
|
||||
local ref=$(git symbolic-ref -q HEAD 2> /dev/null)
|
||||
if [[ -n "$ref" ]]; then
|
||||
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/}
|
||||
else
|
||||
ref=$(git describe --tags --exact-match 2> /dev/null)
|
||||
if [[ -n "$ref" ]]; then
|
||||
SCM_BRANCH=${SCM_THEME_TAG_PREFIX}${ref}
|
||||
else
|
||||
local commit_re='(^remotes/)?(.+-g[a-zA-Z0-9]+)$'
|
||||
local remote_re='^remotes/(.+)$'
|
||||
ref=$(git describe --tags --all --always 2> /dev/null)
|
||||
if [[ "$ref" =~ ${commit_re} ]]; then
|
||||
SCM_BRANCH=${SCM_THEME_COMMIT_PREFIX}${BASH_REMATCH[2]}
|
||||
elif [[ "$ref" =~ ${remote_re} ]]; then
|
||||
SCM_BRANCH=${SCM_THEME_REMOTE_PREFIX}${BASH_REMATCH[1]}
|
||||
local tracking_info="$(grep "${SCM_BRANCH}..." <<< "${status}")"
|
||||
if [[ -n "${tracking_info}" ]]; then
|
||||
[[ "${tracking_info}" =~ .+\[gone\]$ ]] && local branch_gone="true"
|
||||
tracking_info=${tracking_info#\#\# ${SCM_BRANCH}...}
|
||||
tracking_info=${tracking_info% [*}
|
||||
local remote_name=${tracking_info%%/*}
|
||||
local remote_branch=${tracking_info#${remote_name}/}
|
||||
local remote_info=""
|
||||
local num_remotes=$(git remote | wc -l 2> /dev/null)
|
||||
[[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true
|
||||
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) ||
|
||||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
|
||||
remote_info="${remote_name}"
|
||||
[[ "${same_branch_name}" != "true" ]] && remote_info+="/${remote_branch}"
|
||||
elif [[ ${same_branch_name} != "true" ]]; then
|
||||
remote_info="${remote_branch}"
|
||||
fi
|
||||
if [[ -n "${remote_info}" ]];then
|
||||
if [[ "${branch_gone}" = "true" ]]; then
|
||||
SCM_BRANCH+="${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}"
|
||||
else
|
||||
SCM_BRANCH+="${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
SCM_GIT_DETACHED="false"
|
||||
else
|
||||
local detached_prefix=""
|
||||
ref=$(git describe --tags --exact-match 2> /dev/null)
|
||||
if [[ -n "$ref" ]]; then
|
||||
detached_prefix=${SCM_THEME_TAG_PREFIX}
|
||||
else
|
||||
ref=$(git describe --contains --all HEAD 2> /dev/null)
|
||||
ref=${ref#remotes/}
|
||||
[[ -z "$ref" ]] && ref=${SCM_CHANGE}
|
||||
detached_prefix=${SCM_THEME_DETACHED_PREFIX}
|
||||
fi
|
||||
SCM_BRANCH=${detached_prefix}${ref}
|
||||
SCM_GIT_DETACHED="true"
|
||||
fi
|
||||
|
||||
local ahead_re='.+ahead ([0-9]+).+'
|
||||
|
|
@ -138,7 +168,6 @@ function git_prompt_vars {
|
|||
|
||||
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
||||
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
||||
SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null)
|
||||
}
|
||||
|
||||
function svn_prompt_vars {
|
||||
|
|
|
|||
Loading…
Reference in New Issue