Reliably choose XDG_RUNTIME_DIR by putting the username in its path

This commit is contained in:
Danielle McLean 2016-10-06 12:46:17 +11:00
parent b2f5ca7a50
commit 3d5a5260cf
No known key found for this signature in database
GPG key ID: CC91589719027E94

13
.zshenv
View file

@ -1,4 +1,15 @@
: ${XDG_CONFIG_HOME:=~/.config} ${XDG_CACHE_HOME:=~/.cache} ${XDG_DATA_HOME:=~/.local/share} ${XDG_RUNTIME_DIR:=$TMPDIR} # Initialise each of the XDG vars to their default values if they're unset.
: ${XDG_CACHE_HOME:=~/.cache}
: ${XDG_CONFIG_HOME:=~/.config}
: ${XDG_DATA_HOME:=~/.local/share}
# For XDG_RUNTIME_DIR, pick a temporary directory - officially it should be
# destroyed when the user logs out but close enough. The reason for suffixing
# /xdg-$USER is that TMPDIR does not necessarily belong to the current user
# exclusively (although it does under MacOS and PAM).
[[ -z $XDG_RUNTIME_DIR ]] && XDG_RUNTIME_DIR=${TMPDIR%/}/xdg-$USER
export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR
# The real zsh config lives in XDG_CONFIG_HOME! ;)
: ${ZDOTDIR:=$XDG_CONFIG_HOME/zsh} : ${ZDOTDIR:=$XDG_CONFIG_HOME/zsh}
source $ZDOTDIR/zshenv source $ZDOTDIR/zshenv