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
+1
-1
@@ -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
|
||||
fi
|
||||
@@ -1,3 +1,3 @@
|
||||
if (command -v chezmoi &>/dev/null); then
|
||||
if command -v chezmoi &>/dev/null; then
|
||||
source <(chezmoi completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v flux &>/dev/null); then
|
||||
if command -v flux &>/dev/null; then
|
||||
source <(flux completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v glab &>/dev/null); then
|
||||
if command -v glab &>/dev/null; then
|
||||
source <(glab completion)
|
||||
fi
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
if (command -v helm &> /dev/null)
|
||||
if command -v helm &> /dev/null
|
||||
then
|
||||
source <( helm completion bash )
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v k3d &>/dev/null); then
|
||||
if command -v k3d &>/dev/null; then
|
||||
source <(k3d completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v kind &>/dev/null); then
|
||||
if command -v kind &>/dev/null; then
|
||||
source <(kind completion bash)
|
||||
fi
|
||||
@@ -1,4 +1,4 @@
|
||||
if (command -v kubectl &> /dev/null)
|
||||
if command -v kubectl &> /dev/null
|
||||
then
|
||||
source <(kubectl completion bash)
|
||||
fi
|
||||
@@ -1,3 +1,3 @@
|
||||
if (command -v minikube &>/dev/null); then
|
||||
if command -v minikube &>/dev/null; then
|
||||
source <(minikube completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v mise &>/dev/null); then
|
||||
if command -v mise &>/dev/null; then
|
||||
source <(mise completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v podman &>/dev/null); then
|
||||
if command -v podman &>/dev/null; then
|
||||
source <(podman completion bash)
|
||||
fi
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
if ( command -v poetry &> /dev/null )
|
||||
if command -v poetry &> /dev/null
|
||||
then
|
||||
source <(poetry completions bash)
|
||||
fi
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
if (command -v stern &> /dev/null)
|
||||
if command -v stern &> /dev/null
|
||||
then
|
||||
source <(stern --completion bash)
|
||||
fi
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Completion for taskwarrior
|
||||
#
|
||||
if (command -v task &> /dev/null)
|
||||
if command -v task &> /dev/null
|
||||
then
|
||||
complete -o nospace -F _task t
|
||||
fi
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v tea &>/dev/null); then
|
||||
if command -v tea &>/dev/null; then
|
||||
source <(tea completion bash)
|
||||
fi
|
||||
+1
-1
@@ -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})"
|
||||
fi
|
||||
+1
-1
@@ -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"
|
||||
fi
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
|
||||
# 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 -)"
|
||||
fi
|
||||
+1
-1
@@ -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
|
||||
# More information can be found in https://github.com/Canop/broot
|
||||
# This function starts broot and executes the command
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
if (asdf which direnv &>/dev/null); then
|
||||
if asdf which direnv &>/dev/null; then
|
||||
# Hook direnv into your shell.
|
||||
eval "$(asdf exec direnv hook bash)"
|
||||
|
||||
@@ -7,7 +7,7 @@ if (asdf which direnv &>/dev/null); then
|
||||
|
||||
return
|
||||
|
||||
elif (command -v direnv &>/dev/null); then
|
||||
elif command -v direnv &>/dev/null; then
|
||||
# Hook direnv into your shell.
|
||||
eval "$(direnv hook bash)"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (command -v fzf &>/dev/null); then
|
||||
if command -v fzf &>/dev/null; then
|
||||
|
||||
# Shell integration
|
||||
source <(fzf --bash)
|
||||
|
||||
@@ -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:]')"; }
|
||||
fi
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
MY_HISTORY_TOOLS="atuin mcfly"
|
||||
|
||||
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}"
|
||||
break
|
||||
fi
|
||||
@@ -15,7 +15,7 @@ case "${USE_HISTORY_TOOL}" in
|
||||
|
||||
# https://atuin.sh/
|
||||
"atuin")
|
||||
if (command -v atuin &>/dev/null); then
|
||||
if command -v atuin &>/dev/null; then
|
||||
eval "$(atuin init bash)"
|
||||
else
|
||||
echo "${USE_HISTORY_TOOL} command not found"
|
||||
@@ -24,7 +24,7 @@ case "${USE_HISTORY_TOOL}" in
|
||||
|
||||
# https://github.com/cantino/mcfly
|
||||
"mcfly")
|
||||
if (command -v mcfly &>/dev/null); then
|
||||
if command -v mcfly &>/dev/null; then
|
||||
export MCFLY_PROMPT="❯ "
|
||||
export MCFLY_INTERFACE_VIEW=BOTTOM
|
||||
export MCFLY_RESULTS=50
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (which lsd &> /dev/null)
|
||||
if which lsd &> /dev/null
|
||||
then
|
||||
|
||||
# create a aliases
|
||||
|
||||
+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)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# GNU Screen stuff
|
||||
if ( command -v screen &> /dev/null )
|
||||
if command -v screen &> /dev/null
|
||||
then
|
||||
if [[ ${TERM} != screen* ]]
|
||||
then
|
||||
|
||||
+2
-2
@@ -13,12 +13,12 @@ if [[ -z "${DISPLAY}" && $(id -u) -ge 1000 ]] ; then
|
||||
3) VT=vt3 ;;
|
||||
esac
|
||||
|
||||
if ( command -v ck-launch-session &> /dev/null )
|
||||
if command -v ck-launch-session &> /dev/null
|
||||
then
|
||||
EXEC="exec ck-launch-session"
|
||||
fi
|
||||
|
||||
if ( command -v startx &> /dev/null )
|
||||
if command -v startx &> /dev/null
|
||||
then
|
||||
${EXEC} startx 1> ~/.log/xsession-errors 2>&1 -- "${VT}"
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 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 [[ ${TERM} != screen* ]]; then
|
||||
nb_sessions=$(tmux list-session | wc -l)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
# ➜ https://github.com/sharkdp/vivid
|
||||
# 💡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
|
||||
LS_COLORS="$(vivid generate ${THEME})"
|
||||
export LS_COLORS
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
if (command -v zoxide &>/dev/null); then
|
||||
if command -v zoxide &>/dev/null; then
|
||||
eval "$(zoxide init bash)"
|
||||
fi
|
||||
Reference in new issue
Block a user