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:
Xavier LogeraisandCopilot committed 2026-09-28 18:17:13 +02:00
1 parent 6d791dbe29
commit 158c3f99f0
30 files changed
+36 -36

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v aws && command -v aws_completer) &>/dev/null; then if command -v aws &>/dev/null && command -v aws_completer &>/dev/null; then
complete -C aws_completer aws complete -C aws_completer aws
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v chezmoi &>/dev/null); then if command -v chezmoi &>/dev/null; then
source <(chezmoi completion bash) source <(chezmoi completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v flux &>/dev/null); then if command -v flux &>/dev/null; then
source <(flux completion bash) source <(flux completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v glab &>/dev/null); then if command -v glab &>/dev/null; then
source <(glab completion) source <(glab completion)
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
if (command -v helm &> /dev/null) if command -v helm &> /dev/null
then then
source <( helm completion bash ) source <( helm completion bash )
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v k3d &>/dev/null); then if command -v k3d &>/dev/null; then
source <(k3d completion bash) source <(k3d completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v kind &>/dev/null); then if command -v kind &>/dev/null; then
source <(kind completion bash) source <(kind completion bash)
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
if (command -v kubectl &> /dev/null) if command -v kubectl &> /dev/null
then then
source <(kubectl completion bash) source <(kubectl completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v minikube &>/dev/null); then if command -v minikube &>/dev/null; then
source <(minikube completion bash) source <(minikube completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v mise &>/dev/null); then if command -v mise &>/dev/null; then
source <(mise completion bash) source <(mise completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v podman &>/dev/null); then if command -v podman &>/dev/null; then
source <(podman completion bash) source <(podman completion bash)
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
if ( command -v poetry &> /dev/null ) if command -v poetry &> /dev/null
then then
source <(poetry completions bash) source <(poetry completions bash)
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
if (command -v stern &> /dev/null) if command -v stern &> /dev/null
then then
source <(stern --completion bash) source <(stern --completion bash)
fi fi
+1 -1
View File
@@ -1,7 +1,7 @@
# #
# Completion for taskwarrior # Completion for taskwarrior
# #
if (command -v task &> /dev/null) if command -v task &> /dev/null
then then
complete -o nospace -F _task t complete -o nospace -F _task t
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v tea &>/dev/null); then if command -v tea &>/dev/null; then
source <(tea completion bash) source <(tea completion bash)
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v keychain &>/dev/null); then if command -v keychain &>/dev/null; then
eval "$(keychain --inherit any --quiet --noask ~/.ssh/id_{rsa,ed25519})" eval "$(keychain --inherit any --quiet --noask ~/.ssh/id_{rsa,ed25519})"
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v krew &>/dev/null); then if command -v krew &>/dev/null; then
_path_prepend "${KREW_ROOT:-${HOME}/.krew}/bin" _path_prepend "${KREW_ROOT:-${HOME}/.krew}/bin"
fi fi
+1 -1
View File
@@ -2,6 +2,6 @@
# git clone https://github.com/riywo/anyenv ${HOME}/.anyenv # git clone https://github.com/riywo/anyenv ${HOME}/.anyenv
if (command -v anyenv &>/dev/null); then if command -v anyenv &>/dev/null; then
eval "$(anyenv init -)" eval "$(anyenv init -)"
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
if (command -v broot &>/dev/null); then if command -v broot &>/dev/null; then
# This script was automatically generated by the broot program # This script was automatically generated by the broot program
# More information can be found in https://github.com/Canop/broot # More information can be found in https://github.com/Canop/broot
# This function starts broot and executes the command # This function starts broot and executes the command
+2 -2
View File
@@ -1,4 +1,4 @@
if (asdf which direnv &>/dev/null); then if asdf which direnv &>/dev/null; then
# Hook direnv into your shell. # Hook direnv into your shell.
eval "$(asdf exec direnv hook bash)" eval "$(asdf exec direnv hook bash)"
@@ -7,7 +7,7 @@ if (asdf which direnv &>/dev/null); then
return return
elif (command -v direnv &>/dev/null); then elif command -v direnv &>/dev/null; then
# Hook direnv into your shell. # Hook direnv into your shell.
eval "$(direnv hook bash)" eval "$(direnv hook bash)"
+1 -1
View File
@@ -1,4 +1,4 @@
if (command -v fzf &>/dev/null); then if command -v fzf &>/dev/null; then
# Shell integration # Shell integration
source <(fzf --bash) source <(fzf --bash)
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v git && command -v fzf) &>/dev/null; then if command -v git &>/dev/null && command -v fzf &>/dev/null; then
function gsb { git checkout "$(git branch --all | fzf | tr -d '[:space:]')"; } function gsb { git checkout "$(git branch --all | fzf | tr -d '[:space:]')"; }
fi fi
+3 -3
View File
@@ -5,7 +5,7 @@
MY_HISTORY_TOOLS="atuin mcfly" MY_HISTORY_TOOLS="atuin mcfly"
for tool in ${MY_HISTORY_TOOLS}; do for tool in ${MY_HISTORY_TOOLS}; do
if (command -v "${tool}" &>/dev/null); then if command -v "${tool}" &>/dev/null; then
USE_HISTORY_TOOL="${tool}" USE_HISTORY_TOOL="${tool}"
break break
fi fi
@@ -15,7 +15,7 @@ case "${USE_HISTORY_TOOL}" in
# https://atuin.sh/ # https://atuin.sh/
"atuin") "atuin")
if (command -v atuin &>/dev/null); then if command -v atuin &>/dev/null; then
eval "$(atuin init bash)" eval "$(atuin init bash)"
else else
echo "${USE_HISTORY_TOOL} command not found" echo "${USE_HISTORY_TOOL} command not found"
@@ -24,7 +24,7 @@ case "${USE_HISTORY_TOOL}" in
# https://github.com/cantino/mcfly # https://github.com/cantino/mcfly
"mcfly") "mcfly")
if (command -v mcfly &>/dev/null); then if command -v mcfly &>/dev/null; then
export MCFLY_PROMPT="❯ " export MCFLY_PROMPT="❯ "
export MCFLY_INTERFACE_VIEW=BOTTOM export MCFLY_INTERFACE_VIEW=BOTTOM
export MCFLY_RESULTS=50 export MCFLY_RESULTS=50
+1 -1
View File
@@ -1,4 +1,4 @@
if (which lsd &> /dev/null) if which lsd &> /dev/null
then then
# create a aliases # create a aliases
+3 -3
View File
@@ -5,7 +5,7 @@
MY_PROMPT_TOOLS="starship powerline-go" MY_PROMPT_TOOLS="starship powerline-go"
for prompt in ${MY_PROMPT_TOOLS}; do for prompt in ${MY_PROMPT_TOOLS}; do
if (command -v "${prompt}" &>/dev/null); then if command -v "${prompt}" &>/dev/null; then
USE_PROMPT="${prompt}" USE_PROMPT="${prompt}"
break break
fi fi
@@ -15,7 +15,7 @@ case "${USE_PROMPT}" in
# https://starship.rs/ # https://starship.rs/
"starship") "starship")
if (command -v starship &>/dev/null); then if command -v starship &>/dev/null; then
eval "$(starship init bash)" eval "$(starship init bash)"
else else
echo "${USE_PROMPT} command not found" echo "${USE_PROMPT} command not found"
@@ -24,7 +24,7 @@ case "${USE_PROMPT}" in
# https://github.com/justjanne/powerline-go # https://github.com/justjanne/powerline-go
"powerline-go") "powerline-go")
if (command -v powerline-go &>/dev/null); then if command -v powerline-go &>/dev/null; then
function _update_ps1() { 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) 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)
} }
+1 -1
View File
@@ -1,5 +1,5 @@
# GNU Screen stuff # GNU Screen stuff
if ( command -v screen &> /dev/null ) if command -v screen &> /dev/null
then then
if [[ ${TERM} != screen* ]] if [[ ${TERM} != screen* ]]
then then
+2 -2
View File
@@ -13,12 +13,12 @@ if [[ -z "${DISPLAY}" && $(id -u) -ge 1000 ]] ; then
3) VT=vt3 ;; 3) VT=vt3 ;;
esac esac
if ( command -v ck-launch-session &> /dev/null ) if command -v ck-launch-session &> /dev/null
then then
EXEC="exec ck-launch-session" EXEC="exec ck-launch-session"
fi fi
if ( command -v startx &> /dev/null ) if command -v startx &> /dev/null
then then
${EXEC} startx 1> ~/.log/xsession-errors 2>&1 -- "${VT}" ${EXEC} startx 1> ~/.log/xsession-errors 2>&1 -- "${VT}"
fi fi
+1 -1
View File
@@ -1,5 +1,5 @@
# GNU Screen stuff # GNU Screen stuff
if (command -v tmux &>/dev/null); then if command -v tmux &>/dev/null; then
if [ "$(pgrep -u "${UID}" "tmux" | wc -l)" -gt 0 ]; then if [ "$(pgrep -u "${UID}" "tmux" | wc -l)" -gt 0 ]; then
if [[ ${TERM} != screen* ]]; then if [[ ${TERM} != screen* ]]; then
nb_sessions=$(tmux list-session | wc -l) nb_sessions=$(tmux list-session | wc -l)
+1 -1
View File
@@ -3,7 +3,7 @@
# ➜ https://github.com/sharkdp/vivid # ➜ https://github.com/sharkdp/vivid
# 💡Use command `vivid themes` to see available themes # 💡Use command `vivid themes` to see available themes
if (command -v vivid &>/dev/null); then if command -v vivid &>/dev/null; then
THEME=tokyonight-moon THEME=tokyonight-moon
LS_COLORS="$(vivid generate ${THEME})" LS_COLORS="$(vivid generate ${THEME})"
export LS_COLORS export LS_COLORS
+1 -1
View File
@@ -1,3 +1,3 @@
if (command -v zoxide &>/dev/null); then if command -v zoxide &>/dev/null; then
eval "$(zoxide init bash)" eval "$(zoxide init bash)"
fi fi