Skip to content

Commit

Permalink
11/27/2024 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Dec 2, 2024
1 parent 163fc7a commit 99fcc57
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions .10_macos.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi
##### App installs #####

# Homebrew packages
if [[ -x "$(command -v brew)" ]]; then
if command -v brew &> /dev/null; then
command -v gawk > /dev/null || brew install gawk
command -v gdate > /dev/null || brew install coreutils
command -v gsed > /dev/null || brew install gnu-sed
Expand All @@ -34,18 +34,18 @@ if [[ -x "$(command -v brew)" ]]; then
command -v watch > /dev/null || brew install watch
command -v wget > /dev/null || brew install wget

if [[ ! -x "$(command -v hstr)" ]]; then
if ! command -v hstr &> /dev/null; then
brew install hstr
hstr --show-configuration >> ~/.bashrc
fi
fi

# App store applications
if [[ -x "$(command -v brew)" && ! -x "$(command -v mas)" ]]; then
if command -v brew &> /dev/null && ! command -v mas &> /dev/null; then
brew install mas
# Installed applications aren't enumerated immediately, `mas list` may return nothing
fi
# if [[ -x "$(command -v mas)" ]]; then
# if command -v mas &> /dev/null; then
# mas_list=$(mas list)
# # 1Password for Safari
# # echo "${mas_list}" | grep '^1569813296 ' &> /dev/null || mas install 1569813296
Expand Down
10 changes: 5 additions & 5 deletions .20_docker.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export PROGRESS_NO_TRUNC=1


__docker_completions() {
if [[ -x "$(command -v brew)" && -d "/Applications/Docker.app" && -z "$(find "$(brew --prefix)/etc/bash_completion.d" -maxdepth 1 -name "docker*")" ]]; then
if command -v brew &> /dev/null && [[ -d "/Applications/Docker.app" && -z "$(find "$(brew --prefix)/etc/bash_completion.d" -maxdepth 1 -name "docker*")" ]]; then
find "/Applications/Docker.app" -follow -type f -name "*.bash-completion" -exec ln -sf "{}" "$(brew --prefix)/etc/bash_completion.d/" \;
fi
}
Expand All @@ -12,7 +12,7 @@ __docker_completions

__docker_funcs() {
# Auto/lazy-start Docker if it's not running
if [[ -x "$(command -v docker)" ]]; then
if command -v docker &> /dev/null; then
docker() {
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
# macOS
Expand All @@ -28,7 +28,7 @@ __docker_funcs() {
}

alias docker-compose="docker compose --compatibility"
elif [[ -x "$(command -v docker-compose)" ]]; then
elif command -v docker-compose &> /dev/null; then
docker-compose() {
docker ps &> /dev/null # start
command docker-compose "$@"
Expand All @@ -47,7 +47,7 @@ __docker_funcs() {
# Get the digest hash of a Docker image
# @param {string} $1 name[:tag][@digest]
ddigest() {
if [[ -x "$(command -v skopeo)" ]]; then
if command -v skopeo &> /dev/null; then
skopeo inspect --raw "docker://$1" | shasum --algorithm 256 | awk '{print "sha256:"$1}'
else
docker pull "$1" &> /dev/null || true
Expand Down Expand Up @@ -139,7 +139,7 @@ __docker_containers() {
# Execute `jshell` interactively in a Java JDK container
# @param {string=} $1 Image tag
djava() {
if [[ "${1:-}" == "" && -x "$(command -v java)" ]]; then
if [[ "${1:-}" == "" ]] && command -v java &> /dev/null; then
set -- "$(java --version | head -1 | sed 's/"//g' | sed -E 's/(.* )?([0-9]+)\.[0-9]+\.[0-9]+.*/\2/')"
fi

Expand Down
8 changes: 4 additions & 4 deletions .20_git.bash
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Don't use the git from macOS, use the Homebrew version instead
if [[ -x "$(command -v brew)" && ! -f "$(brew --prefix)/bin/git" ]]; then
if command -v brew &> /dev/null && [[ ! -f "$(brew --prefix)/bin/git" ]]; then
brew install git
brew link --overwrite git
fi

if [[ ! -x "$(command -v git)" ]]; then
if ! command -v git &> /dev/null; then
return 0
fi


__git_completions() {
# Bash completions
if [[ -x "$(command -v brew)" && -f "/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash" && ! -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ]]; then
if command -v brew &> /dev/null && [[ -f "/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash" && ! -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ]]; then
ln -sf "/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash" "$(brew --prefix)/etc/bash_completion.d/"
fi
}
Expand All @@ -26,7 +26,7 @@ __git_funcs() {
fi

# Shell alias Git aliases from the .gitconfig
for al in $(git --list-cmds=alias); do
for al in $(git --list-cmds=alias; git --list-cmds=main); do
# shellcheck disable=SC2139
alias g${al}="git ${al}"
if type __git_aliased_command &> /dev/null; then
Expand Down
12 changes: 6 additions & 6 deletions .20_kubernetes.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __kube_completions() {

# NOTE: `autoload -Uz compinit && compinit` will need to happen before sourcing any of these!

if [[ -x "$(command -v helm)" ]]; then
if command -v helm &> /dev/null; then
helm() {
unset -f "$0"
# shellcheck disable=SC1090
Expand All @@ -13,7 +13,7 @@ __kube_completions() {
}
fi

if [[ -x "$(command -v kops)" ]]; then
if command -v kops &> /dev/null; then
kops() {
unset -f "$0"
# shellcheck disable=SC1090
Expand All @@ -22,7 +22,7 @@ __kube_completions() {
}
fi

if [[ -x "$(command -v kubectl)" ]]; then
if command -v kubectl &> /dev/null; then
kubectl() {
unset -f "$0"
# shellcheck disable=SC1090
Expand All @@ -31,7 +31,7 @@ __kube_completions() {
}
fi

if [[ -x "$(command -v minikube)" ]]; then
if command -v minikube &> /dev/null; then
minikube() {
unset -f "$0"
# shellcheck disable=SC1090
Expand All @@ -40,7 +40,7 @@ __kube_completions() {
}
fi

if [[ -x "$(command -v stern)" ]]; then
if command -v stern &> /dev/null; then
stern() {
unset -f "$0"
# shellcheck disable=SC1090
Expand Down Expand Up @@ -163,7 +163,7 @@ __kube_funcs() {
# @param {number=} $2 Tail length
# @param {...string} Additional kubectl options
klogs() {
if [[ -x "$(command -v stern)" ]]; then
if command -v stern &> /dev/null; then
stern --timestamps --tail "${2:-0}" --selector "app=$1"
else
kubectl logs --all-containers --timestamps --follow --max-log-requests=9999 "--tail=${2:-0}" --selector="app=$1"
Expand Down
2 changes: 1 addition & 1 deletion .20_python.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ __python_pyenv() {
__python_pyenv

__python_pip() {
if [[ ! -x "$(command -v pip)" && -x "$(command -v pip3)" ]]; then
if ! command -v pip &> /dev/null && command -v pip3 &> /dev/null; then
alias pip=pip3
fi
}
Expand Down
4 changes: 2 additions & 2 deletions .20_temporal.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reset back to non-beta functionality
if [[ -x "$(command -v tctl)" ]]; then
if command -v tctl &> /dev/null; then
tctl config set version current
fi

Expand All @@ -11,7 +11,7 @@ fi
__temporal_completions() {
# NOTE: `autoload -Uz compinit && compinit` will need to happen before sourcing any of these!

if [[ -x "$(command -v tctl)" ]]; then
if command -v tctl &> /dev/null; then
tctl() {
unset -f "$0"
# shellcheck disable=SC1090
Expand Down
10 changes: 5 additions & 5 deletions .20_terraform.bash
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
__terraform_install() {
if [[ -x "$(command -v terraform)" ]]; then
if command -v terraform &> /dev/null; then
return 0
fi
# Lazy install
terraform() {
if [[ -x "$(command -v brew)" ]]; then
if command -v brew &> /dev/null; then
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
fi
Expand All @@ -16,14 +16,14 @@ __terraform_install


__tflint_install() {
if [[ -x "$(command -v tflint)" ]]; then
if command -v tflint &> /dev/null; then
return 0
fi
# Lazy install
tflint() {
if [[ -x "$(command -v brew)" ]]; then
if command -v brew &> /dev/null; then
brew install tflint
elif [[ -x "$(command -v docker)" ]]; then
elif command -v docker &> /dev/null; then
docker run --rm --volume "$(pwd):/data" --tty "ghcr.io/terraform-linters/tflint" "$@"
return $?
fi
Expand Down
2 changes: 1 addition & 1 deletion .90_powerline.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [[ -d ~/Library/Fonts && "$(find ~/Library/Fonts -maxdepth 1 -follow -type f
fi

# If installed run it
if [[ -x "$(command -v powerline-daemon)" ]]; then
if command -v powerline-daemon &> /dev/null; then
powerline-daemon --quiet
export POWERLINE_BASH_CONTINUATION=1
export POWERLINE_BASH_SELECT=1
Expand Down
16 changes: 8 additions & 8 deletions .everythingrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Bash: .bash_profile (macOS default) -> .profile (Ubuntu default) -> .bashrc -> .everythingrc
# zsh: .zshrc (always executed) -> .everythingrc

: ${SHELL:=$(which "$(ps -o comm= $$ | sed 's/^-*//')")}
SHELL=$(which "$(ps -o comm= $$ | sed 's/^-*//')")

# https://docs.brew.sh/Shell-Completion
: ${HOMEBREW_PREFIX:=$(if type brew &> /dev/null; then brew --prefix; fi)}

if [[ ! -x "$(command -v brew)" && -f /opt/homebrew/bin/brew ]]; then
if ! command -v brew &> /dev/null && [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi


##### Bash #####

if [[ -x "$(command -v brew)" ]]; then
if command -v brew &> /dev/null; then
# Load bash-completion
if [[ "$(basename "${SHELL}")" == "bash" ]]; then
__bash_completion() {
Expand Down Expand Up @@ -69,7 +69,7 @@ __bashrc_misc() {
}

# Don't be a savage
if [[ -x "$(command -v nano)" ]]; then
if command -v nano &> /dev/null; then
EDITOR=$(pinpoint nano)
export EDITOR
fi
Expand Down Expand Up @@ -115,7 +115,7 @@ __bashrc_misc() {
alias yeet="rm -rf"

# Polyfills
if [[ ! -x "$(command -v beep)" ]]; then
if ! command -v beep &> /dev/null; then
alias beep="echo -ne '\007'"
fi
}
Expand Down Expand Up @@ -145,7 +145,7 @@ __bashrc_ides

__bashrc_golang() {
# Set path environment variables
if [[ -x "$(command -v go)" ]]; then
if command -v go &> /dev/null; then
if [[ ! -d "${GOROOT}" ]]; then
GOROOT=$(realpath "$(which go)" | sed 's/\/bin\/go$//')
export GOROOT
Expand Down Expand Up @@ -188,7 +188,7 @@ __bashrc_java

__bashrc_mysql() {
# Set path environment variables
if [[ -x "$(command -v brew)" ]]; then
if command -v brew &> /dev/null; then
while read -r DIR; do
if [[ -d "${DIR}/bin" ]]; then
export PATH="${DIR}/bin:${PATH}"
Expand Down Expand Up @@ -230,7 +230,7 @@ __bashrc_ruby() {
fi

# Auto-load the latest Ruby version
if [[ -x "$(command -v chruby)" && -d ~/.rubies ]]; then
if command -v chruby &> /dev/null && [[ -d ~/.rubies ]]; then
chruby "$(ls -1 ~/.rubies/ | sort | tail -1)"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ find "${HOME}" -maxdepth 1 -name ".*.bash" -type l ! -exec test -e {} \; -delete
link "$(pwd)" ".*"

# Reload powerline if installed
if [[ -x "$(command -v powerline-daemon)" ]]; then
if command -v powerline-daemon &> /dev/null; then
powerline-daemon --quiet --replace
fi
2 changes: 1 addition & 1 deletion settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail


# Git settings
if [[ -x "$(command -v git)" && -s ~/.gitignore_global ]]; then
if command -v git &> /dev/null && [[ -s ~/.gitignore_global ]]; then
git config --global core.excludesfile ~/.gitignore_global
fi

Expand Down

0 comments on commit 99fcc57

Please sign in to comment.