]> arthur.barton.de Git - ax-zsh.git/commitdiff
New "30_env" core plugin
authorAlexander Barton <alex@barton.de>
Sat, 27 Aug 2016 22:07:38 +0000 (00:07 +0200)
committerAlexander Barton <alex@barton.de>
Sat, 27 Aug 2016 22:07:38 +0000 (00:07 +0200)
Move setting of XDG_CACHE_HOME and ZSH_CACHE_DIR from 20_home to this
new plugin, and set XDG_RUNTIME_DIR, too.

In addition, make sure that TMPDIR is reset when it has been deleted but
TMP is available (this is the case for setgid binaries on Linux, for
example, which is quite common when using screen(1)).

README.md
core/20_home/20_home.zprofile
core/30_env/30_env.zprofile [new file with mode: 0644]
core/30_env/30_env.zshrc [new file with mode: 0644]

index 27ac06ae71992a98bbc10566c6a766f5198f8bd4..73cd5ccc6086b7a856ad8a46fb4304199709c28c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -86,5 +86,6 @@ Validated and/or set up by core plugins:
 * `PS1`
 * `SHORT_HOST`
 * `TERM`
+* `XDG_RUNTIME_DIR`
 * `XDG_CACHE_HOME`
 * `ZSH_CACHE_DIR`
index e4d19b172031ff2d6d1726a402df04f6914f0035..adab90b318f3e78773ca735ac2ccffd60ee016e2 100644 (file)
@@ -8,14 +8,6 @@
        && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
        || export LOCAL_HOME="$HOME"
 
-# Setup XDG cache directory
-export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
-mkdir -p "$XDG_CACHE_HOME"
-
-# Setup ZSH cache directory
-export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
-mkdir -p "$ZSH_CACHE_DIR"
-
 # Update PATH to include directories inside of the $HOME directory
 typeset -U path
 for dir in ~/bin ~/sbin ~/Applications; do
diff --git a/core/30_env/30_env.zprofile b/core/30_env/30_env.zprofile
new file mode 100644 (file)
index 0000000..8fc6f9d
--- /dev/null
@@ -0,0 +1,17 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 30_env.zprofile: Setup environment
+
+# Setup XDG cache directory
+[[ -z "$XDG_CACHE_HOME" ]] && XDG_CACHE_HOME="$LOCAL_HOME/.cache"
+export XDG_CACHE_HOME
+mkdir -p "$XDG_CACHE_HOME"
+
+# Setup XDG runtime directory
+[[ -z "$XDG_RUNTIME_DIR" ]] && XDG_RUNTIME_DIR="${TMPDIR:-/tmp/${UID}-runtime-dir}"
+export XDG_RUNTIME_DIR
+mkdir -p "$XDG_CACHE_HOME"
+
+# Setup ZSH cache directory
+[[ -z "$ZSH_CACHE_DIR" ]] && ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
+export ZSH_CACHE_DIR
+mkdir -p "$ZSH_CACHE_DIR"
diff --git a/core/30_env/30_env.zshrc b/core/30_env/30_env.zshrc
new file mode 100644 (file)
index 0000000..b8ee833
--- /dev/null
@@ -0,0 +1,13 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 30_env.zshrc: Setup environment
+
+# Setup TMPDIR. Try to reset TMPDIR (when it is not set but TMP is), which is
+# common in tools like screen(1) because Linux removes some varibes for
+# "setgit" tools (see <https://bugzilla.redhat.com/show_bug.cgi?id=129682#c1>).
+# And therefore this has to be checked here, because inside of screen probably
+# no login shell is started ...
+[[ -z "$TMPDIR" && -n "$TMP" ]] && TMPDIR="$TMP"
+
+# Make sure TMP and TMPDIR become exported when they are set:
+[[ -n "$TMP" ]] && export TMP
+[[ -n "$TMPDIR" ]] && export TMPDIR