1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # 30_env.ax-io: Setup environment
5 if [[ -z "$TZ" && -r "/etc/timezone" ]]; then
6 TZ=$(<"/etc/timezone") export TZ
9 # Validate temporary directory
10 if [[ -z "$TMPDIR" ]]; then
11 echo "WARNING: \"TMPDIR\" is not set, using /tmp as default!" >&2
14 if [[ ! -w "$TMPDIR" ]]; then
15 echo "WARNING: Temporary directory \"$TMPDIR\" is not writable!" >&2
17 # Make sure TMPDIR ends in a slash (like on macOS by default): this makes its
18 # usage a bit safer ...
25 # Setup XDG cache directory
26 if [[ -z "$XDG_CACHE_HOME" ]]; then
27 XDG_CACHE_HOME="$LOCAL_HOME/.cache"
29 if [[ ! -d "$XDG_CACHE_HOME" ]]; then
30 mkdir -p "$XDG_CACHE_HOME"
31 chmod 0700 "$XDG_CACHE_HOME"
35 # Setup XDG runtime directory
36 if [[ -z "$XDG_RUNTIME_DIR" ]]; then
37 XDG_RUNTIME_DIR="${TMPDIR:-/tmp/${UID}-runtime-dir}"
39 if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
40 mkdir -p "$XDG_RUNTIME_DIR"
41 chmod 0700 "$XDG_RUNTIME_DIR"
43 export XDG_RUNTIME_DIR
45 # Setup ZSH cache directory
46 if [[ -z "$ZSH_CACHE_DIR" ]]; then
47 ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
49 if [[ ! -d "$ZSH_CACHE_DIR" ]]; then
50 mkdir -p "$ZSH_CACHE_DIR"
51 chmod 0700 "$ZSH_CACHE_DIR"