34 lines
894 B
Bash
34 lines
894 B
Bash
#!/usr/bin/env zsh
|
|
# Eryn Wells <eryn@erynwells.me>
|
|
|
|
# See https://specifications.freedesktop.org/basedir/latest/ for definitions of
|
|
# these paths.
|
|
|
|
|
|
function init-env-default-xdg-vars
|
|
{
|
|
zmodload zsh/zutil
|
|
|
|
local -a opt_create
|
|
zparseopts -a opt_args -D -E -F - \
|
|
{c,-create,-no-create}=opt_create
|
|
|
|
export \
|
|
XDG_BIN_HOME=${XDG_BIN_HOME:-$HOME/.local/bin} \
|
|
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} \
|
|
XDG_CONFIG_HOME=${XDG_CACHE_HOME:-$HOME/.config} \
|
|
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} \
|
|
XDG_STATE_HOME=${XDG_DATA_HOME:-$HOME/.local/state}
|
|
|
|
if [[ $opt_create[(I)--no-create] -ne 0 ]]; then
|
|
mkdir -p -m 0700 \
|
|
$XDG_BIN_HOME \
|
|
$XDG_CACHE_HOME \
|
|
$XDG_CONFIG_HOME \
|
|
$XDG_DATA_HOME \
|
|
$XDG_STATE_HOME
|
|
fi
|
|
}
|
|
|
|
|
|
init-env-default-xdg-vars "$@"
|