Merge pull request #2061 from gaelicWizard/lib/helpers

lib/helpers: fixes, improvements, consolations, constellations, and a partridge in a pear tree
pull/2101/head
Noah Gorny 2022-03-01 23:21:27 +02:00 committed by GitHub
commit 34bc37c178
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 83 additions and 91 deletions

0
.editorconfig 100755 → 100644
View File

0
.gitignore vendored 100755 → 100644
View File

View File

@ -8,16 +8,19 @@
: "${BASH_IT_LOAD_PRIORITY_COMPLETION:=350}" : "${BASH_IT_LOAD_PRIORITY_COMPLETION:=350}"
BASH_IT_LOAD_PRIORITY_SEPARATOR="---" BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
# Handle the different ways of running `sed` without generating a backup file based on OS # Handle the different ways of running `sed` without generating a backup file based on provenance:
# - GNU sed (Linux) uses `-i` # - GNU sed (Linux) uses `-i''`
# - BSD sed (macOS) uses `-i ''` # - BSD sed (FreeBSD/macOS/Solaris/PlayStation) uses `-i ''`
# To use this in Bash-it for inline replacements with `sed`, use the following syntax: # To use this in Bash-it for inline replacements with `sed`, use the following syntax:
# sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file # sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file
BASH_IT_SED_I_PARAMETERS=('-i')
# shellcheck disable=SC2034 # expected for this case # shellcheck disable=SC2034 # expected for this case
case "$OSTYPE" in if sed --version > /dev/null 2>&1; then
'darwin'*) BASH_IT_SED_I_PARAMETERS=('-i' '') ;; # GNU sed accepts "long" options
esac BASH_IT_SED_I_PARAMETERS=('-i')
else
# BSD sed errors on invalid option `-`
BASH_IT_SED_I_PARAMETERS=('-i' '')
fi
function _command_exists() { function _command_exists() {
_about 'checks for existence of a command' _about 'checks for existence of a command'
@ -255,10 +258,10 @@ function _bash-it_update_migrate_and_restart() {
_about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)' _about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)'
_param '1: Which branch to checkout to' _param '1: Which branch to checkout to'
_param '2: Which type of version we are using' _param '2: Which type of version we are using'
if git checkout "$1" &> /dev/null; then if git checkout "${1?}" &> /dev/null; then
echo "Bash-it successfully updated." echo "Bash-it successfully updated."
echo "" echo ""
echo "Migrating your installation to the latest $2 version now..." echo "Migrating your installation to the latest ${2:-} version now..."
_bash-it-migrate _bash-it-migrate
echo "" echo ""
echo "All done, enjoy!" echo "All done, enjoy!"
@ -275,7 +278,7 @@ function _bash-it-update-() {
_param '1: What kind of update to do (stable|dev)' _param '1: What kind of update to do (stable|dev)'
_group 'lib' _group 'lib'
local silent word DIFF version TARGET revision status revert log_color num_of_lines description i RESP local silent word DIFF version TARGET revision status revert log_color RESP
for word in "$@"; do for word in "$@"; do
if [[ "${word}" == "--silent" || "${word}" == "-s" ]]; then if [[ "${word}" == "--silent" || "${word}" == "-s" ]]; then
silent=true silent=true
@ -300,7 +303,7 @@ function _bash-it-update-() {
BASH_IT_DEVELOPMENT_BRANCH="master" BASH_IT_DEVELOPMENT_BRANCH="master"
fi fi
# Defaults to stable update # Defaults to stable update
if [[ -z "$1" || "$1" == "stable" ]]; then if [[ -z "${1:-}" || "$1" == "stable" ]]; then
version="stable" version="stable"
TARGET=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2> /dev/null) TARGET=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2> /dev/null)
@ -331,15 +334,7 @@ function _bash-it-update-() {
log_color="%Cred" log_color="%Cred"
fi fi
for i in $(git rev-list --merges --first-parent "${revision}"); do git log --format="${log_color}%h: %s (%an)" "${revision}"
num_of_lines=$(git log -1 --format=%B "$i" | awk '!/^[[:space:]]*$/ {++i} END{print i}')
if [[ "$num_of_lines" -eq 1 ]]; then
description="%s"
else
description="%b"
fi
git log --format="${log_color}%h: $description (%an)" -1 "$i"
done
echo "" echo ""
if [[ -n "${silent}" ]]; then if [[ -n "${silent}" ]]; then
@ -542,7 +537,7 @@ function _bash-it-profile-save() {
fi fi
done done
done done
if [[ -z "$something_exists" ]]; then if [[ -z "${something_exists:-}" ]]; then
echo "It seems like no configuration was enabled.." echo "It seems like no configuration was enabled.."
echo "Make sure to double check that this is the wanted behavior." echo "Make sure to double check that this is the wanted behavior."
fi fi
@ -560,30 +555,30 @@ _bash-it-profile-load-parse-profile() {
_example '$ _bash-it-profile-load-parse-profile "profile.bash_it" "dry"' _example '$ _bash-it-profile-load-parse-profile "profile.bash_it" "dry"'
local -i num=0 local -i num=0
local line local line enable_func subdirectory component to_enable bad
while read -r -a line; do while read -r -a line; do
((++num)) ((++num))
# Ignore comments and empty lines # Ignore comments and empty lines
[[ -z "${line[*]}" || "${line[*]}" =~ ^#.* ]] && continue [[ -z "${line[*]}" || "${line[*]}" =~ ^#.* ]] && continue
local enable_func="_enable-${line[0]}" enable_func="_enable-${line[0]}"
local subdirectory=${line[0]} subdirectory=${line[0]}
local component=${line[1]} component=${line[1]}
local to_enable=("${BASH_IT}/$subdirectory/available/$component.${subdirectory%s}"*.bash) to_enable=("${BASH_IT}/$subdirectory/available/$component.${subdirectory%s}"*.bash)
# Ignore botched lines # Ignore botched lines
if [[ ! -e "${to_enable[0]}" ]]; then if [[ ! -e "${to_enable[0]}" ]]; then
echo -e "${echo_orange?}Bad line(#$num) in profile, aborting load...${line[*]}${echo_reset_color?}" echo -e "${echo_orange?}Bad line(#$num) in profile, aborting load...${line[*]}${echo_reset_color?}"
local bad="bad line" bad="bad line"
break break
fi fi
# Do not actually modify config on dry run # Do not actually modify config on dry run
[[ -z $2 ]] || continue [[ -z "${2:-}" ]] || continue
# Actually enable the component # Actually enable the component
$enable_func "$component" $enable_func "$component"
done < "$1" done < "${1?}"
# Make sure to propagate the error # Make sure to propagate the error
[[ -z $bad ]] [[ -z ${bad:-} ]]
} }
_bash-it-profile-list() { _bash-it-profile-list() {
@ -602,7 +597,7 @@ _bash-it-profile-rm() {
about 'Removes a profile from the "profiles" directory' about 'Removes a profile from the "profiles" directory'
_group 'lib' _group 'lib'
local name="$1" local name="${1:-}"
if [[ -z $name ]]; then if [[ -z $name ]]; then
echo -e "${echo_orange?}Please specify profile name to remove...${echo_reset_color?}" echo -e "${echo_orange?}Please specify profile name to remove...${echo_reset_color?}"
return 1 return 1
@ -628,7 +623,7 @@ _bash-it-profile-load() {
_about 'loads a configuration from the "profiles" directory' _about 'loads a configuration from the "profiles" directory'
_group 'lib' _group 'lib'
local name="$1" local name="${1:-}"
if [[ -z $name ]]; then if [[ -z $name ]]; then
echo -e "${echo_orange?}Please specify profile name to load, not changing configuration...${echo_reset_color?}" echo -e "${echo_orange?}Please specify profile name to load, not changing configuration...${echo_reset_color?}"
return 1 return 1
@ -659,19 +654,15 @@ function _bash-it-restart() {
_about 'restarts the shell in order to fully reload it' _about 'restarts the shell in order to fully reload it'
_group 'lib' _group 'lib'
local saved_pwd="${PWD}" init_file="${BASH_IT_BASHRC:-${HOME?}/.bashrc}" exec "${0#-}" --rcfile "${BASH_IT_BASHRC:-${HOME?}/.bashrc}"
exec "${0/-/}" --rcfile <(echo "source \"${init_file}\"; cd \"$saved_pwd\"")
} }
function _bash-it-reload() { function _bash-it-reload() {
_about 'reloads a profile file' _about 'reloads the shell initialization file'
_group 'lib' _group 'lib'
pushd "${BASH_IT?}" > /dev/null || return
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BASH_IT_BASHRC:-${HOME?}/.bashrc}" source "${BASH_IT_BASHRC:-${HOME?}/.bashrc}"
popd > /dev/null || return
} }
function _bash-it-describe() { function _bash-it-describe() {
@ -709,7 +700,9 @@ function _on-disable-callback() {
_group 'lib' _group 'lib'
local callback="${1}_on_disable" local callback="${1}_on_disable"
_command_exists "$callback" && "$callback" if _command_exists "$callback"; then
"$callback"
fi
} }
function _disable-all() { function _disable-all() {
@ -728,8 +721,8 @@ function _disable-plugin() {
_example '$ disable-plugin rvm' _example '$ disable-plugin rvm'
_group 'lib' _group 'lib'
_disable-thing "plugins" "plugin" "$1" _disable-thing "plugins" "plugin" "${1?}"
_on-disable-callback "$1" _on-disable-callback "${1?}"
} }
function _disable-alias() { function _disable-alias() {
@ -738,7 +731,7 @@ function _disable-alias() {
_example '$ disable-alias git' _example '$ disable-alias git'
_group 'lib' _group 'lib'
_disable-thing "aliases" "alias" "$1" _disable-thing "aliases" "alias" "${1?}"
} }
function _disable-completion() { function _disable-completion() {
@ -747,7 +740,7 @@ function _disable-completion() {
_example '$ disable-completion git' _example '$ disable-completion git'
_group 'lib' _group 'lib'
_disable-thing "completion" "completion" "$1" _disable-thing "completion" "completion" "${1?}"
} }
function _disable-thing() { function _disable-thing() {
@ -781,7 +774,7 @@ function _disable-thing() {
# Either one will be matched by this glob # Either one will be matched by this glob
for plugin in "${BASH_IT}/enabled"/[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" "${BASH_IT}/$subdirectory/enabled/"{[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"}; do for plugin in "${BASH_IT}/enabled"/[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" "${BASH_IT}/$subdirectory/enabled/"{[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"}; do
if [[ -e "${plugin}" ]]; then if [[ -e "${plugin}" ]]; then
rm "${plugin}" rm -f "${plugin}"
plugin= plugin=
break break
fi fi
@ -792,10 +785,11 @@ function _disable-thing() {
fi fi
fi fi
_bash-it-clean-component-cache "${file_type}" _bash-it-component-cache-clean "${file_type}"
if [[ "$file_entity" = "all" ]]; then if [[ "$file_entity" == "all" ]]; then
printf '%s\n' "$file_entity $(_bash-it-pluralize-component "$file_type") disabled." _bash-it-component-pluralize "$file_type" file_type
printf '%s\n' "$file_entity ${file_type} disabled."
else else
printf '%s\n' "$file_entity disabled." printf '%s\n' "$file_entity disabled."
fi fi
@ -807,7 +801,7 @@ function _enable-plugin() {
_example '$ enable-plugin rvm' _example '$ enable-plugin rvm'
_group 'lib' _group 'lib'
_enable-thing "plugins" "plugin" "$1" "$BASH_IT_LOAD_PRIORITY_PLUGIN" _enable-thing "plugins" "plugin" "${1?}" "$BASH_IT_LOAD_PRIORITY_PLUGIN"
} }
function _enable-plugins() { function _enable-plugins() {
@ -821,7 +815,7 @@ function _enable-alias() {
_example '$ enable-alias git' _example '$ enable-alias git'
_group 'lib' _group 'lib'
_enable-thing "aliases" "alias" "$1" "$BASH_IT_LOAD_PRIORITY_ALIAS" _enable-thing "aliases" "alias" "${1?}" "$BASH_IT_LOAD_PRIORITY_ALIAS"
} }
function _enable-aliases() { function _enable-aliases() {
@ -835,7 +829,7 @@ function _enable-completion() {
_example '$ enable-completion git' _example '$ enable-completion git'
_group 'lib' _group 'lib'
_enable-thing "completion" "completion" "$1" "$BASH_IT_LOAD_PRIORITY_COMPLETION" _enable-thing "completion" "completion" "${1?}" "$BASH_IT_LOAD_PRIORITY_COMPLETION"
} }
function _enable-thing() { function _enable-thing() {
@ -890,7 +884,7 @@ function _enable-thing() {
ln -s "../$subdirectory/available/$to_enable" "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" ln -s "../$subdirectory/available/$to_enable" "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}"
fi fi
_bash-it-clean-component-cache "${file_type}" _bash-it-component-cache-clean "${file_type}"
printf '%s\n' "$file_entity enabled with priority $use_load_priority." printf '%s\n' "$file_entity enabled with priority $use_load_priority."
} }
@ -908,7 +902,7 @@ function _help-aliases() {
_example '$ alias-help' _example '$ alias-help'
_example '$ alias-help git' _example '$ alias-help git'
if [[ -n "$1" ]]; then if [[ -n "${1:-}" ]]; then
case "$1" in case "$1" in
custom) custom)
alias_path='custom.aliases.bash' alias_path='custom.aliases.bash'
@ -1021,14 +1015,14 @@ function pathmunge() {
# a subshell to simplify our search to a simple `cd ..` and `[[ -r $1 ]]` # a subshell to simplify our search to a simple `cd ..` and `[[ -r $1 ]]`
# without any external dependencies. Let the shell do what it's good at. # without any external dependencies. Let the shell do what it's good at.
function _bash-it-find-in-ancestor() ( function _bash-it-find-in-ancestor() (
about 'searches parents of the current directory for any of the specified file names' : _about 'searches parents of the current directory for any of the specified file names'
group 'helpers' : _group 'helpers'
param '*: names of files or folders to search for' : _param '*: names of files or folders to search for'
returns '0: prints path of closest matching ancestor directory to stdout' : _returns '0: prints path of closest matching ancestor directory to stdout'
returns '1: no match found' : _returns '1: no match found'
returns '2: improper usage of shell builtin' # uncommon : _returns '2: improper usage of shell builtin' # uncommon
example '_bash-it-find-in-ancestor .git .hg' : _example '_bash-it-find-in-ancestor .git .hg'
example '_bash-it-find-in-ancestor GNUmakefile Makefile makefile' : _example '_bash-it-find-in-ancestor GNUmakefile Makefile makefile'
local kin local kin
# To keep things simple, we do not search the root dir. # To keep things simple, we do not search the root dir.

View File

@ -70,7 +70,7 @@ function _bash-it-search() {
return 0 return 0
;; ;;
'-r' | '--refresh') '-r' | '--refresh')
_bash-it-clean-component-cache _bash-it-component-cache-clean
;; ;;
'-c' | '--no-color') '-c' | '--no-color')
BASH_IT_SEARCH_USE_COLOR=false BASH_IT_SEARCH_USE_COLOR=false
@ -266,9 +266,11 @@ function _bash-it-search-result() {
shift shift
local color_component color_enable color_disable color_off local color_component color_enable color_disable color_off
local color_sep=':' line local match_color compatible_action suffix opposite_suffix
local color_sep=':' line match matched temp
local -i modified=0 enabled=0 len
local -a matches=() local -a matches=()
# Discard any empty arguments # Discard any empty arguments
while IFS='' read -r line; do while IFS='' read -r line; do
[[ -n "${line}" ]] && matches+=("$line") [[ -n "${line}" ]] && matches+=("$line")
@ -290,18 +292,13 @@ function _bash-it-search-result() {
color_off='' color_off=''
fi fi
local match
local -i modified=0
if [[ "${#matches[@]}" -gt 0 ]]; then if [[ "${#matches[@]}" -gt 0 ]]; then
printf "${color_component}%13s${color_sep}${color_off} " "${component}" printf "${color_component}%13s${color_sep}${color_off} " "${component}"
for match in "${matches[@]}"; do for match in "${matches[@]}"; do
local -i enabled=0 enabled=0
_bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1 _bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1
local match_color compatible_action suffix opposite_suffix
if ((enabled)); then if ((enabled)); then
match_color="${color_enable}" match_color="${color_enable}"
suffix="${suffix_enable}" suffix="${suffix_enable}"
@ -314,8 +311,8 @@ function _bash-it-search-result() {
compatible_action="enable" compatible_action="enable"
fi fi
local matched="${match}${suffix}" matched="${match}${suffix}"
local -i len="${#matched}" len="${#matched}"
printf '%b' "${match_color}${matched}" # print current state printf '%b' "${match_color}${matched}" # print current state
if [[ "${action}" == "${compatible_action}" ]]; then if [[ "${action}" == "${compatible_action}" ]]; then
@ -327,7 +324,7 @@ function _bash-it-search-result() {
modified=1 modified=1
# shellcheck disable=SC2034 # no idea if `$result` is ever used # shellcheck disable=SC2034 # no idea if `$result` is ever used
result=$("${action_func}" "${match}") result=$("${action_func}" "${match}")
local temp="color_${compatible_action}" temp="color_${compatible_action}"
match_color="${!temp}" match_color="${!temp}"
_bash-it-rewind "${len}" _bash-it-rewind "${len}"
printf '%b' "${match_color}${match}${opposite_suffix}" printf '%b' "${match_color}${match}${opposite_suffix}"
@ -336,7 +333,7 @@ function _bash-it-search-result() {
printf '%b' "${color_off} " printf '%b' "${color_off} "
done done
((modified)) && _bash-it-clean-component-cache "${component}" ((modified)) && _bash-it-component-cache-clean "${component}"
printf "\n" printf "\n"
fi fi
} }

View File

@ -63,7 +63,7 @@ function _bash-it-array-dedup() {
# Outputs a full path of the grep found on the filesystem # Outputs a full path of the grep found on the filesystem
function _bash-it-grep() { function _bash-it-grep() {
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}" : "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}" printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}"
} }
# Runs `grep` with extended regular expressions # Runs `grep` with extended regular expressions
@ -91,7 +91,7 @@ function _bash-it-component-help() {
function _bash-it-component-cache-file() { function _bash-it-component-cache-file() {
local _component_to_cache _file_path _result="${2:-${FUNCNAME[0]//-/_}}" local _component_to_cache _file_path _result="${2:-${FUNCNAME[0]//-/_}}"
_bash-it-component-pluralize "${1?${FUNCNAME[0]}: component name required}" _component_to_cache _bash-it-component-pluralize "${1?${FUNCNAME[0]}: component name required}" _component_to_cache
_file_path="${XDG_CACHE_HOME:-${BASH_IT?}/tmp/cache}${XDG_CACHE_HOME:+/bash_it}/${_component_to_cache?}" _file_path="${XDG_CACHE_HOME:-${HOME?}/.cache}/bash/${_component_to_cache?}"
[[ -f "${_file_path}" ]] || mkdir -p "${_file_path%/*}" [[ -f "${_file_path}" ]] || mkdir -p "${_file_path%/*}"
printf -v "${_result?}" '%s' "${_file_path}" printf -v "${_result?}" '%s' "${_file_path}"
} }
@ -121,19 +121,17 @@ function _bash-it-component-pluralize() {
printf -v "${_result?}" '%s' "${_component_to_plural}" printf -v "${_result?}" '%s' "${_component_to_plural}"
} }
function _bash-it-clean-component-cache() { function _bash-it-component-cache-clean() {
local component="$1" local component="${1:-}"
local cache local cache
local -a BASH_IT_COMPONENTS=(aliases plugins completions) local -a components=('aliases' 'plugins' 'completions')
if [[ -z "${component}" ]]; then if [[ -z "${component}" ]]; then
for component in "${BASH_IT_COMPONENTS[@]}"; do for component in "${components[@]}"; do
_bash-it-clean-component-cache "${component}" _bash-it-component-cache-clean "${component}"
done done
else else
_bash-it-component-cache-file "${component}" cache _bash-it-component-cache-file "${component}" cache
if [[ -f "${cache}" ]]; then : >| "${cache:?}"
rm -f "${cache}"
fi
fi fi
} }
@ -170,18 +168,22 @@ function _bash-it-component-list-disabled() {
function _bash-it-component-item-is-enabled() { function _bash-it-component-item-is-enabled() {
local component_type item_name each_file local component_type item_name each_file
if [[ -f "${1}" ]]; then if [[ -f "${1?}" ]]; then
item_name="$(_bash-it-get-component-name-from-path "${1}")" item_name="$(_bash-it-get-component-name-from-path "${1}")"
component_type="$(_bash-it-get-component-type-from-path "${1}")" component_type="$(_bash-it-get-component-type-from-path "${1}")"
else else
component_type="${1}" item_name="${2}" component_type="${1}" item_name="${2?}"
fi fi
for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \ for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \ "${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do "${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do
[[ -f "${each_file}" ]] && return if [[ -f "${each_file}" ]]; then
return 0
fi
done done
return 1
} }
# Checks if a given item is disabled for a particular component/file-type. # Checks if a given item is disabled for a particular component/file-type.

View File

@ -196,12 +196,11 @@ function setup_upower {
percent="$1" percent="$1"
BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM"
function upower { function upower {
case $1 in case $1 in
'-e'|'--enumerate') '-e'|'--enumerate')
echo "$BAT0" # don't just `echo` twice because `grep` will close the pipe after matching the first line...
echo "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" echo "$BAT0"$'\n'"/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
;; ;;
'-i'|'--show-info') '-i'|'--show-info')
if [[ $2 == "$BAT0" ]] if [[ $2 == "$BAT0" ]]

View File

@ -134,7 +134,7 @@ function _git-remote-info {
elif [[ ${same_branch_name} != "true" ]]; then elif [[ ${same_branch_name} != "true" ]]; then
remote_info="${VCS_STATUS_REMOTE_BRANCH}" remote_info="${VCS_STATUS_REMOTE_BRANCH}"
fi fi
if [[ -n "${remote_info}" ]];then if [[ -n "${remote_info:-}" ]];then
# no support for gone remote branches in gitstatusd # no support for gone remote branches in gitstatusd
local branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX}" local branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX}"
echo "${branch_prefix}${remote_info}" echo "${branch_prefix}${remote_info}"
@ -155,7 +155,7 @@ function _git-remote-info {
elif [[ ${same_branch_name} != "true" ]]; then elif [[ ${same_branch_name} != "true" ]]; then
remote_info="\$(_git-upstream-branch)" remote_info="\$(_git-upstream-branch)"
fi fi
if [[ -n "${remote_info}" ]];then if [[ -n "${remote_info:-}" ]];then
local branch_prefix local branch_prefix
if _git-upstream-branch-gone; then if _git-upstream-branch-gone; then
branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX}" branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX}"