From 4fd66d4751653ee3d173ac5c32257db207834bb1 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 17 Feb 2021 22:04:36 +0000 Subject: [PATCH] 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. --- themes/base.theme.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index b4798b9c..1c4e0c4c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -248,7 +248,9 @@ function git_prompt_vars { 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 ' ')" + local Data + readarray Data <<< "$(git stash list 2> /dev/null)" + stash_count=${Data//[![:digit:]]/} fi [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" fi