Setup XDG_ on Darwin

This commit is contained in:
David Tomaschik
2025-09-25 02:53:39 -07:00
parent 2b31d4d5d2
commit e270bac5f2

View File

@@ -87,5 +87,26 @@ export LVM_SUPPRESS_FD_WARNINGS=1
# Default disable SSH forwarding in EARTHLY # Default disable SSH forwarding in EARTHLY
export EARTHLY_SSH_AUTH_SOCK="" export EARTHLY_SSH_AUTH_SOCK=""
# shellcheck source=/dev/null # Setup XDG-like dirs on MacOS
test -e "$HOME/.localenv" && . "$HOME/.localenv" # Based on https://leebyron.com/til/mac-xdg/
if [ "$(uname)" = "Darwin" ] ; then
original_options=$(echo "$-")
set -a
# Anything set here will be exported
: "${XDG_BIN_HOME:=$HOME/.local/bin}"
: "${XDG_CACHE_HOME:=$HOME/Library/Caches}"
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${XDG_DATA_HOME:=$HOME/.local/share}"
: "${XDG_RUNTIME_DIR:=$TMPDIR/runtime-$UID}"
: "${XDG_STATE_HOME:=$HOME/.local/state}"
set -f # Temporarily disable globbing to handle options with special characters
set -- "-$original_options"
unset original_options
fi
if test -e "$HOME/.localenv"; then
# shellcheck source=/dev/null
. "$HOME/.localenv"
else
true
fi