[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
# 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
export HOMEBREW_NO_ENV_HINTS=1
[ -d /opt/homebrew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
if [ -d /opt/homebrew ]; then
export HOMEBREW_NO_ENV_HINTS=1
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Flushes the DNS cache on macOS
function flushdns() {
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
echo 'This only works on macOS...'
fi
@@ -31,6 +31,10 @@ function itsok() {
# Runs a brew bundle check and installs missing packages
# Usage: 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
}
@@ -39,18 +43,23 @@ function update-brewfile() {
# app_name<TAB>app_path<TAB>app_type
# where app_type can be "persisentApps" or "other"
# Usage: 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
while read entry; do
app_name=$(echo "$entry" | cut -d $'\t' -f 1)
app_path=$(echo "$entry" | cut -d $'\t' -f 2)
app_type=$(echo "$entry" | cut -d $'\t' -f 3)
idx=$((idx+1))
dockutil --no-restart -a "$app_path" > /dev/null 2>&1
idx=$((idx + 1))
dockutil --no-restart -a "$app_path" >/dev/null 2>&1
if [ "$app_type" = "persisentApps" ]; then
dockutil --move "$app_name" -p $idx
fi
done < ~/.dotfiles/macos/.config/dotfiles/dockConfig.txt
done <~/.dotfiles/macos/.config/dotfiles/dockConfig.txt
killall Dock
}

View File

@@ -2,7 +2,11 @@
# Get the list of AWS profiles
function awsprofiles() {
profiles=$(aws --no-cli-pager configure list-profiles 2> /dev/null)
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)
if [[ -z "$profiles" ]]; then
echo "No AWS profiles found in '$HOME/.aws/config, check if ~/.aws/config exists and properly configured.'"
return 1
@@ -13,6 +17,13 @@ function awsprofiles() {
# login via SSO to AWS
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 region=""
@@ -37,7 +48,7 @@ function awslogin() {
# Get available profiles
local available_profiles
available_profiles=$(aws --no-cli-pager configure list-profiles 2> /dev/null)
available_profiles=$(aws --no-cli-pager configure list-profiles 2>/dev/null)
if [[ -z "$available_profiles" ]]; then
echo "No AWS profiles found in ~/.aws/config"
return 1
@@ -92,7 +103,11 @@ function awslogin() {
# Clear AWS credentials from environment
function awslogout() {
aws sso logout --profile "${AWS_PROFILE:-default}" 2> /dev/null
if ! [ -x "$(command -v aws)" ]; then
echo "AWS CLI not installed."
return 1
fi
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
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