Use BASH instead of tr(1) & wc(1)

Most of the time, people use programs like tr(1) and wc(1) when they're
woefully unnecessary, serving only to make their programs inefficient
and bloated. BASH itself can deal with most of these tasks with
absolute ease. This is one such situation.
pull/1840/head
terminalforlife 2021-02-17 22:04:36 +00:00
parent f4299f437c
commit 4fd66d4751
1 changed files with 3 additions and 1 deletions

View File

@ -248,7 +248,9 @@ function git_prompt_vars {
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
stash_count=${VCS_STATUS_STASHES} stash_count=${VCS_STATUS_STASHES}
else else
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" local Data
readarray Data <<< "$(git stash list 2> /dev/null)"
stash_count=${Data//[![:digit:]]/}
fi fi
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
fi fi