[multiple] Move shell files to define load order

This commit is contained in:
Andrew Williams
2026-01-07 15:20:19 +00:00
parent c76580004c
commit a7ee37ce1e
11 changed files with 71 additions and 32 deletions

View File

@@ -0,0 +1,5 @@
# shellcheck shell=bash
# Override XDG cache location for macOS to use the standard Library/Caches directory
export XDG_CACHE_HOME="$HOME/Library/Caches"
export XDG_RUNTIME_DIR="${TMPDIR}runtime-${UID}"

View File

@@ -1,17 +1,17 @@
# shellcheck shell=bash # shellcheck shell=bash
# Override XDG cache location for macOS to use the standard Library/Caches directory
export XDG_CACHE_HOME="$HOME/Library/Caches"
export XDG_RUNTIME_DIR="${TMPDIR}runtime-${UID}"
# Configure Homebrew environment # Configure Homebrew environment
if [ -d /opt/homebrew ]; then
export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_ENV_HINTS=1
[ -d /opt/homebrew ] && eval "$(/opt/homebrew/bin/brew shellenv)" eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Flushes the DNS cache on macOS # Flushes the DNS cache on macOS
function flushdns() { function flushdns() {
if [[ $(uname) == "Darwin" ]]; then if [[ $(uname) == "Darwin" ]]; then
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; echo 'DNS cache flushed.' sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
echo 'DNS cache flushed.'
else else
echo 'This only works on macOS...' echo 'This only works on macOS...'
fi fi
@@ -31,6 +31,10 @@ function itsok() {
# Runs a brew bundle check and installs missing packages # Runs a brew bundle check and installs missing packages
# Usage: update-brewfile # Usage: update-brewfile
function update-brewfile() { function update-brewfile() {
if ! [ -x $(command -v brew) ]; then
echo "Homebrew is not installed. Please install it first."
return 1
fi
brew bundle check --global || brew bundle --cleanup -f --global brew bundle check --global || brew bundle --cleanup -f --global
} }
@@ -39,7 +43,12 @@ function update-brewfile() {
# app_name<TAB>app_path<TAB>app_type # app_name<TAB>app_path<TAB>app_type
# where app_type can be "persisentApps" or "other" # where app_type can be "persisentApps" or "other"
# Usage: update-dock # Usage: update-dock
function update-dock() { function update-dock() {
if ! [ -x $(command -v dockutil) ]; then
echo "dockutil is not installed. Please install it via Homebrew: brew install dockutil"
return 1
fi
idx=1 idx=1
while read entry; do while read entry; do
app_name=$(echo "$entry" | cut -d $'\t' -f 1) app_name=$(echo "$entry" | cut -d $'\t' -f 1)

View File

@@ -2,6 +2,10 @@
# Get the list of AWS profiles # Get the list of AWS profiles
function awsprofiles() { function awsprofiles() {
if ! [ -x $(command -v aws) ]; then
echo "AWS CLI not installed."
return 1
fi
profiles=$(aws --no-cli-pager configure list-profiles 2>/dev/null) profiles=$(aws --no-cli-pager configure list-profiles 2>/dev/null)
if [[ -z "$profiles" ]]; then if [[ -z "$profiles" ]]; then
echo "No AWS profiles found in '$HOME/.aws/config, check if ~/.aws/config exists and properly configured.'" echo "No AWS profiles found in '$HOME/.aws/config, check if ~/.aws/config exists and properly configured.'"
@@ -13,6 +17,13 @@ function awsprofiles() {
# login via SSO to AWS # login via SSO to AWS
function awslogin() { function awslogin() {
for cmd in "aws" "fzf"; do
if ! [ -x "$(command -v $cmd)" ]; then
echo "$cmd is not installed. Please install it to use awslogin."
return 1
fi
done
local profile="" local profile=""
local region="" local region=""
@@ -92,6 +103,10 @@ function awslogin() {
# Clear AWS credentials from environment # Clear AWS credentials from environment
function awslogout() { function awslogout() {
if ! [ -x "$(command -v aws)" ]; then
echo "AWS CLI not installed."
return 1
fi
aws sso logout --profile "${AWS_PROFILE:-default}" 2>/dev/null aws sso logout --profile "${AWS_PROFILE:-default}" 2>/dev/null
unset AWS_PROFILE AWS_PROFILE_ACTIVE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_CREDENTIAL_EXPIRATION unset AWS_PROFILE AWS_PROFILE_ACTIVE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_CREDENTIAL_EXPIRATION
echo "AWS profile and credentials cleared." echo "AWS profile and credentials cleared."

View File

@@ -0,0 +1,10 @@
# shellcheck shell=bash
# Terraform helpers
if [ -x "$(command -v terraform)" ]; then
# Define a shared cache location for Terraform plugins
export TF_PLUGIN_CACHE_DIR="${XDG_CACHE_HOME}/terraform-plugins"
alias tfplan="terraform plan -out=tfplan.binary"
alias tf="terraform"
fi