From: Alexander Barton Date: Sat, 27 Aug 2016 22:07:38 +0000 (+0200) Subject: New "30_env" core plugin X-Git-Url: https://arthur.barton.de/gitweb/?p=ax-zsh.git;a=commitdiff_plain;h=3e1f6b6eb01abfbb219964f1d6bc25faf6e7e953 New "30_env" core plugin 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)). --- diff --git a/README.md b/README.md index 27ac06a..73cd5cc 100644 --- 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` diff --git a/core/20_home/20_home.zprofile b/core/20_home/20_home.zprofile index e4d19b1..adab90b 100644 --- a/core/20_home/20_home.zprofile +++ b/core/20_home/20_home.zprofile @@ -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 index 0000000..8fc6f9d --- /dev/null +++ b/core/30_env/30_env.zprofile @@ -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 index 0000000..b8ee833 --- /dev/null +++ b/core/30_env/30_env.zshrc @@ -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 ). +# 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