Created
August 30, 2023 21:55
-
-
Save garthk/d493a29a87e86e5c9876753aa836b668 to your computer and use it in GitHub Desktop.
zsh XDG directory specification environment variables plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XDG_DATA_DIRS=/usr/local/share:/usr/share | |
XDG_CONFIG_DIRS=/etc/xdg | |
case $(uname) in | |
Linux) | |
XDG_CONFIG_HOME="$HOME/.config" | |
XDG_CACHE_HOME="$HOME/.cache" | |
XDG_DATA_HOME="$HOME/.local/share" | |
XDG_STATE_HOME="$HOME/.local/state" | |
XDG_RUNTIME_DIR="/run/user/$(id -u)" | |
;; | |
Darwin) | |
XDG_CONFIG_DIRS="/Library/Application Support:$XDG_CONFIG_DIRS" | |
XDG_DATA_DIRS="/Library:$XDG_DATA_DIRS" | |
XDG_CACHE_HOME="$HOME/Library/Caches" | |
XDG_CONFIG_HOME="$HOME/Library/Application Support" | |
XDG_DATA_HOME="$HOME/Library/Application Support" | |
XDG_RUNTIME_DIR="$HOME/Library/Caches/TemporaryItems" | |
XDG_STATE_HOME="$HOME/Library/Application Support" | |
;; | |
esac | |
export XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sets variables according to the [XDG Base Directory Specification])https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). Tailored for macOS with reference to File System Basics. See in particular its advice regarding
~/Library/Preferences
that:… hence
XDG_CONFIG_HOME
not using it.Do let me know if you've any references that'll guide changes!