perf: remove unnecessary subshells in command -v checks
Replace 'if (command -v x &>/dev/null); then' with 'if command -v x &>/dev/null; then' across completion.d, rc.d and profile.d. Parentheses forced a subshell fork for every 'if' check, which is unnecessary overhead since command -v runs fine in the current shell. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
6d791dbe29
commit
158c3f99f0
30 files changed
+36
-36
No files matched your search
+3
-3
@@ -5,7 +5,7 @@
|
||||
MY_PROMPT_TOOLS="starship powerline-go"
|
||||
|
||||
for prompt in ${MY_PROMPT_TOOLS}; do
|
||||
if (command -v "${prompt}" &>/dev/null); then
|
||||
if command -v "${prompt}" &>/dev/null; then
|
||||
USE_PROMPT="${prompt}"
|
||||
break
|
||||
fi
|
||||
@@ -15,7 +15,7 @@ case "${USE_PROMPT}" in
|
||||
|
||||
# https://starship.rs/
|
||||
"starship")
|
||||
if (command -v starship &>/dev/null); then
|
||||
if command -v starship &>/dev/null; then
|
||||
eval "$(starship init bash)"
|
||||
else
|
||||
echo "${USE_PROMPT} command not found"
|
||||
@@ -24,7 +24,7 @@ case "${USE_PROMPT}" in
|
||||
|
||||
# https://github.com/justjanne/powerline-go
|
||||
"powerline-go")
|
||||
if (command -v powerline-go &>/dev/null); then
|
||||
if command -v powerline-go &>/dev/null; then
|
||||
function _update_ps1() {
|
||||
PS1=$(powerline-go -jobs "$(jobs -p | wc -l)" -error $? -modules "ssh,host,wsl,user,cwd,direnv,venv,perms,git,jobs,exit,root" -modules-right "docker,docker-context,kube,terraform-workspace,termtitle" -newline)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user