Skip to content

Commit

Permalink
edit: mac xdg
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed Jan 14, 2025
1 parent 83a2a49 commit 2a68b80
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions entries/mac xdg.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ environment variables that many programs will look for to determine where they
read and write files. This is particularly nice for keeping your `~` home
directory from becoming littered with various dot-file config scripts.

[xdg-base-dirs-standard]:
https://specifications.freedesktop.org/basedir-spec/latest/

This is a growing standard on Linux but not the default on macOS. However it's
easy to set up!

Create (with `sudo`) the file `/etc/zshenv`[^or-alternatives] (or `~/.zshenv`
for your user only) with the following contents:

```sh
```zsh
# Define XDG Base directory environment variables
export XDG_BIN_HOME="$HOME/.local/bin"
export XDG_CACHE_HOME="$HOME/Library/Caches"
Expand All @@ -43,8 +46,9 @@ Many programs will now automatically start using these directories, and
existing config files can be moved into the `~/.cache/{program}/` folders.

If you're writing distributing your own program which defines local
configuration files, please do check if `$XDG_CONFIG_HOME` is set and if so
prefer using XDG paths for your config files.
configuration files, please do check if `$XDG_CONFIG_HOME` or
`$XDG_CONFIG_DIRS` is set and if so prefer using XDG paths for your config
files.

[^or-alternatives]: Assuming you are using the default zsh as your shell. If
using a different shell then sub in the equivalent environment config file.

0 comments on commit 2a68b80

Please sign in to comment.