mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 12:26:39 +00:00
Add command-exists shell helper
This commit is contained in:
@@ -27,7 +27,7 @@ alias di="colordiff"
|
|||||||
alias devnullsmtp="java -jar $DOTBIN/DevNullSmtp.jar"
|
alias devnullsmtp="java -jar $DOTBIN/DevNullSmtp.jar"
|
||||||
|
|
||||||
# Homebrew
|
# Homebrew
|
||||||
if (( $+commands[brew] )); then
|
if command-exists brew; then
|
||||||
alias br="brew"
|
alias br="brew"
|
||||||
alias ca="brew cask"
|
alias ca="brew cask"
|
||||||
alias cask="brew cask"
|
alias cask="brew cask"
|
||||||
@@ -36,7 +36,7 @@ if (( $+commands[brew] )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Flutter
|
# Flutter
|
||||||
if (( $+commands[flutter] )); then
|
if command-exists flutter; then
|
||||||
alias fl="flutter"
|
alias fl="flutter"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ docker_remove_exited () {
|
|||||||
docker rm "$(docker ps -f='status=exited' -q)"
|
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 ice from'gh-r' as'program' mv'ctop-* -> ctop'
|
||||||
zinit light bcicen/ctop
|
zinit light bcicen/ctop
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ alias kc="kubectl"
|
|||||||
alias hl="helm"
|
alias hl="helm"
|
||||||
alias mk="minikube"
|
alias mk="minikube"
|
||||||
|
|
||||||
if (( $+commands[kubectl] )); then
|
if command-exists kubectl; then
|
||||||
# lazy-load kubectl setup
|
# lazy-load kubectl setup
|
||||||
_kubectl() {
|
_kubectl() {
|
||||||
unset -f _kubectl
|
unset -f _kubectl
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
alias le="less"
|
alias le="less"
|
||||||
|
|
||||||
# Enable syntax highlighting via source-highlight
|
# 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 LESSOPEN="| src-hilite-lesspipe.sh %s"
|
||||||
export LESS=" -R "
|
export LESS=" -R "
|
||||||
elif [ -f "/usr/share/source-highlight/src-hilite-lesspipe.sh" ]; then
|
elif [ -f "/usr/share/source-highlight/src-hilite-lesspipe.sh" ]; then
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ install_python_global_packages () {
|
|||||||
'yamllint'
|
'yamllint'
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]] && (( $+commands[brew] )); then
|
if [[ "$OSTYPE" == "darwin"* ]] && command-exists brew; then
|
||||||
brew list python >/dev/null || brew install python
|
brew list python >/dev/null || brew install python
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local pipcmd="pip"
|
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 setuptools
|
||||||
"$pipcmd" install --upgrade "${packages[@]}"
|
"$pipcmd" install --upgrade "${packages[@]}"
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ alias bo="bundle open"
|
|||||||
alias bp="bundle package"
|
alias bp="bundle package"
|
||||||
alias bu="bundle update"
|
alias bu="bundle update"
|
||||||
|
|
||||||
if (( $+commands[rbenv] )); then
|
if command-exists rbenv; then
|
||||||
# lazy-load rbenv
|
# lazy-load rbenv
|
||||||
rbenv() {
|
rbenv() {
|
||||||
load-rbenv
|
load-rbenv
|
||||||
|
|||||||
8
zshrc
8
zshrc
@@ -9,6 +9,14 @@ if [[ "$OSTYPE" == "darwin"* ]] && [ -f "/etc/zshrc" ]; then
|
|||||||
source "/etc/zshrc"
|
source "/etc/zshrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# Helpers
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
command-exists() {
|
||||||
|
command -v "$1" &> /dev/null
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Zinit
|
# Zinit
|
||||||
|
|||||||
Reference in New Issue
Block a user