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 TMPDIR="$(dirname $(mktemp -ut tmp.XXXXXXXXXX))/"
12 echo "WARNING: \"TMPDIR\" is not set, using \"$TMPDIR\" as default!" >&2
14 if [[ ! -w "$TMPDIR" ]]; then
15 echo "WARNING: Temporary directory \"$TMPDIR\" is not writable!" >&2
18 # Setup XDG cache directory
19 if [[ -z "$XDG_CACHE_HOME" ]]; then
20 XDG_CACHE_HOME="$LOCAL_HOME/.cache"
22 if [[ ! -d "$XDG_CACHE_HOME" ]]; then
23 mkdir -p "$XDG_CACHE_HOME"
24 chmod 0700 "$XDG_CACHE_HOME"
28 # Setup XDG runtime directory
29 if [[ -z "$XDG_RUNTIME_DIR" ]]; then
30 XDG_RUNTIME_DIR="$TMPDIR/runtime-dir.$UID"
32 if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
33 mkdir -p "$XDG_RUNTIME_DIR"
34 chmod 0700 "$XDG_RUNTIME_DIR"
36 export XDG_RUNTIME_DIR
38 # Setup ZSH cache directory
39 if [[ -z "$ZSH_CACHE_DIR" ]]; then
40 ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
42 if [[ ! -d "$ZSH_CACHE_DIR" ]]; then
43 mkdir -p "$ZSH_CACHE_DIR"
44 chmod 0700 "$ZSH_CACHE_DIR"