diff --git a/README.md b/README.md index 314e77b8..a696894e 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ Setting this flag globally has the same effect as `SCM_CHECK=true`, but only for ### Speed up git status calculations -As an alternative to ignoring repo status entirely, you can try out the `gitstatusd` plugin. +As an alternative to ignoring repo status entirely, you can try out the `gitstatus` plugin. This plugin speeds up all `git status` calculations by up to 10x times! **NOTE**: You will need to clone `gitstatus` repo from [here](https://github.com/romkatv/gitstatus). diff --git a/lib/helpers.bash b/lib/helpers.bash index 9c4b3c43..f3bd2e0b 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -322,7 +322,7 @@ _on-disable-callback() { _about 'Calls the disabled plugin destructor, if present' _param '1: plugin name' - _example '$ _on-disable-callback gitstatusd' + _example '$ _on-disable-callback gitstatus' _group 'lib' callback=$1_on_disable diff --git a/plugins/available/gitstatus.plugin.bash b/plugins/available/gitstatus.plugin.bash new file mode 100644 index 00000000..d48d0569 --- /dev/null +++ b/plugins/available/gitstatus.plugin.bash @@ -0,0 +1,23 @@ +cite about-plugin +about-plugin 'speeds up your life by using gitstatus for git status calculations. install from https://github.com/romkatv/gitstatus' + + +function gitstatus_on_disable() { + about 'Destructor of gitstatus plugin' + group 'gitstatus' + + unset SCM_GIT_USE_GITSTATUS + gitstatus_stop +} + +[[ "$SCM_CHECK" == "true" ]] || return # No scm-check + +[[ $- == *i* ]] || return # non-interactive shell + +SCM_GIT_GITSTATUS_PLUGIN_SH_LOC=${SCM_GIT_GITSTATUS_PLUGIN_SH_LOC:="$HOME/gitstatus/gitstatus.plugin.sh"} +if [[ -f "${SCM_GIT_GITSTATUS_PLUGIN_SH_LOC}" ]]; then + source "${SCM_GIT_GITSTATUS_PLUGIN_SH_LOC}" + # Start the actual gitstatus binary + gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 + export SCM_GIT_USE_GITSTATUS=true +fi diff --git a/plugins/available/gitstatusd.plugin.bash b/plugins/available/gitstatusd.plugin.bash deleted file mode 100644 index 3551c6f9..00000000 --- a/plugins/available/gitstatusd.plugin.bash +++ /dev/null @@ -1,23 +0,0 @@ -cite about-plugin -about-plugin 'speeds up your life by using gitstatusd for git status calculations. install from https://github.com/romkatv/gitstatus' - - -function gitstatusd_on_disable() { - about 'Destructor of gitstatusd plugin' - group 'gitstatusd' - - unset SCM_GIT_USE_GITSTATUSD - gitstatus_stop -} - -[[ "$SCM_CHECK" == "true" ]] || return # No scm-check - -[[ $- == *i* ]] || return # non-interactive shell - -SCM_GIT_GITSTATUSD_PLUGIN_SH_LOC=${SCM_GIT_GITSTATUSD_PLUGIN_SH_LOC:="$HOME/gitstatus/gitstatus.plugin.sh"} -if [[ -f "${SCM_GIT_GITSTATUSD_PLUGIN_SH_LOC}" ]]; then - source "${SCM_GIT_GITSTATUSD_PLUGIN_SH_LOC}" - # Start the actual gitstatusd binary - gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 - export SCM_GIT_USE_GITSTATUSD=true -fi diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 6fa8e516..40ac5c32 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -32,9 +32,9 @@ export TODO="t" # Set this to false to turn off version control status checking within the prompt for all themes export SCM_CHECK=true -# Set to actual location of gitstatusd.plugin.sh if installed -#export SCM_GIT_GITSTATUSD_PLUGIN_SH_LOC="$HOME/gitstatus/gitstatus.plugin.sh" -# per default gitstatusd uses 2 times as many threads as CPU cores, you can change this here if you must +# Set to actual location of gitstatus.plugin.sh if installed +#export SCM_GIT_GITSTATUS_PLUGIN_SH_LOC="$HOME/gitstatus/gitstatus.plugin.sh" +# per default gitstatus uses 2 times as many threads as CPU cores, you can change this here if you must #export GITSTATUS_NUM_THREADS=8 # Set Xterm/screen/Tmux title with only a short hostname. diff --git a/test/lib/search.bats b/test/lib/search.bats index 60c06be2..c7bda191 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -40,7 +40,7 @@ function local_teardown { run _bash-it-search 'git' --no-color assert_line -n 0 ' aliases: git gitsvn ' assert_line -n 1 -p ' plugins:' - for plugin in "autojump" "git" "gitstatusd" "git-subrepo" "jgitflow" "jump" + for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump" do echo $plugin assert_line -n 1 -p $plugin diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 26527659..61671b51 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -34,8 +34,8 @@ SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true} SCM_GIT_SHOW_COMMIT_COUNT=${SCM_GIT_SHOW_COMMIT_COUNT:=true} -SCM_GIT_USE_GITSTATUSD=${SCM_GIT_USE_GITSTATUSD:=false} -SCM_GIT_GITSTATUSD_RAN=${SCM_GIT_GITSTATUSD_RAN:=false} +SCM_GIT_USE_GITSTATUS=${SCM_GIT_USE_GITSTATUS:=false} +SCM_GIT_GITSTATUS_RAN=${SCM_GIT_GITSTATUS_RAN:=false} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -193,10 +193,10 @@ function git_prompt_minimal_info { } function git_prompt_vars { - if ${SCM_GIT_USE_GITSTATUSD} && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT}" == "ok-sync" ]]; then # use faster gitstatusd - SCM_GIT_GITSTATUSD_RAN=true # use this in githelpers and below to choose gitstatusd output + if ${SCM_GIT_USE_GITSTATUS} && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT}" == "ok-sync" ]]; then # use faster gitstatus + SCM_GIT_GITSTATUS_RAN=true # use this in githelpers and below to choose gitstatus output else - SCM_GIT_GITSTATUSD_RAN=false + SCM_GIT_GITSTATUS_RAN=false fi if _git-branch &> /dev/null; then @@ -214,7 +214,7 @@ function git_prompt_vars { SCM_BRANCH="${detached_prefix}\$(_git-friendly-ref)" fi - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then commits_behind=${VCS_STATUS_COMMITS_BEHIND} commits_ahead=${VCS_STATUS_COMMITS_AHEAD} else @@ -231,7 +231,7 @@ function git_prompt_vars { if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then local stash_count - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then stash_count=${VCS_STATUS_STASHES} else stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" @@ -241,7 +241,7 @@ function git_prompt_vars { SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if ! _git-hide-status; then - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then untracked_count=${VCS_STATUS_NUM_UNTRACKED} unstaged_count=${VCS_STATUS_NUM_UNSTAGED} staged_count=${VCS_STATUS_NUM_STAGED} @@ -259,7 +259,7 @@ function git_prompt_vars { fi fi - # no if for gitstatusd here, user extraction is not supported by it + # no if for gitstatus here, user extraction is not supported by it [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && SCM_BRANCH+="$(git_user_info)" SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} diff --git a/themes/githelpers.theme.bash b/themes/githelpers.theme.bash index fd5b3ce7..2d5829ff 100644 --- a/themes/githelpers.theme.bash +++ b/themes/githelpers.theme.bash @@ -9,7 +9,7 @@ function _git-symbolic-ref { # same commit. _git-branch is used to explicitly choose the checked-out # branch. function _git-branch { - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then test -n "${VCS_STATUS_LOCAL_BRANCH}" && echo "${VCS_STATUS_LOCAL_BRANCH}" || return 1 else git symbolic-ref -q --short HEAD 2> /dev/null || return 1 @@ -17,7 +17,7 @@ function _git-branch { } function _git-tag { - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then test -n "${VCS_STATUS_TAG}" && echo "${VCS_STATUS_TAG}" else git describe --tags --exact-match 2> /dev/null @@ -29,7 +29,7 @@ function _git-commit-description { } function _git-short-sha { - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then echo ${VCS_STATUS_COMMIT:0:7} else git rev-parse --short HEAD @@ -38,8 +38,8 @@ function _git-short-sha { # Try the checked-out branch first to avoid collision with branches pointing to the same ref. function _git-friendly-ref { - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then - _git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatusd + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then + _git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatus else _git-branch || _git-tag || _git-commit-description || _git-short-sha fi @@ -119,7 +119,7 @@ function _git-status-counts { function _git-remote-info { # prompt handling only, reimplement because patching the routine below gets ugly - if [[ "${SCM_GIT_GITSTATUSD_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then [[ "${VCS_STATUS_REMOTE_NAME}" == "" ]] && return [[ "${VCS_STATUS_LOCAL_BRANCH}" == "${VCS_STATUS_REMOTE_BRANCH}" ]] && local same_branch_name=true local same_branch_name=