Add command-exists shell helper

This commit is contained in:
2020-05-23 19:16:06 +01:00
parent ba559be4bc
commit d4d64f654e
7 changed files with 16 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ alias di="colordiff"
alias devnullsmtp="java -jar $DOTBIN/DevNullSmtp.jar"
# Homebrew
if (( $+commands[brew] )); then
if command-exists brew; then
alias br="brew"
alias ca="brew cask"
alias cask="brew cask"
@@ -36,7 +36,7 @@ if (( $+commands[brew] )); then
fi
# Flutter
if (( $+commands[flutter] )); then
if command-exists flutter; then
alias fl="flutter"
fi

View File

@@ -10,7 +10,7 @@ docker_remove_exited () {
docker rm "$(docker ps -f='status=exited' -q)"
}
if (( $+commands[docker] )); then
if command-exists docker; then
zinit ice from'gh-r' as'program' mv'ctop-* -> ctop'
zinit light bcicen/ctop
fi

View File

@@ -6,7 +6,7 @@ alias kc="kubectl"
alias hl="helm"
alias mk="minikube"
if (( $+commands[kubectl] )); then
if command-exists kubectl; then
# lazy-load kubectl setup
_kubectl() {
unset -f _kubectl

View File

@@ -5,7 +5,7 @@
alias le="less"
# Enable syntax highlighting via source-highlight
if (( $+commands[src-hilite-lesspipe.sh] )); then
if command-exists "src-hilite-lesspipe.sh"; then
export LESSOPEN="| src-hilite-lesspipe.sh %s"
export LESS=" -R "
elif [ -f "/usr/share/source-highlight/src-hilite-lesspipe.sh" ]; then

View File

@@ -10,12 +10,12 @@ install_python_global_packages () {
'yamllint'
)
if [[ "$OSTYPE" == "darwin"* ]] && (( $+commands[brew] )); then
if [[ "$OSTYPE" == "darwin"* ]] && command-exists brew; then
brew list python >/dev/null || brew install python
fi
local pipcmd="pip"
if (( $+commands[pip3] )); then; pipcmd="pip3"; fi
if command-exists pip3; then pipcmd="pip3"; fi
"$pipcmd" install --upgrade setuptools
"$pipcmd" install --upgrade "${packages[@]}"

View File

@@ -50,7 +50,7 @@ alias bo="bundle open"
alias bp="bundle package"
alias bu="bundle update"
if (( $+commands[rbenv] )); then
if command-exists rbenv; then
# lazy-load rbenv
rbenv() {
load-rbenv