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 user_tmpdir="$TMPDIR$UID"
13 mkdir -p "$user_tmpdir" >/dev/null 2>&1
14 if [[ -w "$user_tmpdir" ]]; then
15 TMPDIR="$user_tmpdir/"
18 echo "WARNING: \"TMPDIR\" is not set, using \"$TMPDIR\" as default!" >&2
21 if [[ ! -w "$TMPDIR" ]]; then
22 echo "WARNING: Temporary directory \"$TMPDIR\" is not writable!" >&2
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/runtime-dir.$UID"
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"