From 1e7b4c8cacd020e94323974977902579eb90f858 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 11 Dec 2022 15:36:25 +0100 Subject: [PATCH] Look for configuration files in $ZDOTDIR This allows you to set/override the ZDOTDIR environment variable in your ~/.zshenv file to have different "sets" of AX-ZSH configurations in different ZDOTDIR folders. For example, for different terminal emulator applications, system architectures or hosts. If ZDOTDIR is not set, $HOME is used (so no functional changes when the ZDOTDIR environment variable is not set). --- ax.zsh | 2 +- install.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ax.zsh b/ax.zsh index e21b246..b2ee3db 100644 --- a/ax.zsh +++ b/ax.zsh @@ -228,7 +228,7 @@ fi [[ -n "$SHELL" ]] || export SHELL=$(command -v zsh) # Make sure that "AXZSH" variable is set and exported -[[ -n "$AXZSH" ]] || export AXZSH="$HOME/.axzsh" +[[ -n "$AXZSH" ]] || export AXZSH="${ZDOTDIR:-$HOME}/.axzsh" # Check for "debug mode" ... if [[ -f "$AXZSH/debug" || -f "$HOME/.axzsh.debug" ]]; then diff --git a/install.sh b/install.sh index 4c50197..6d7b22a 100755 --- a/install.sh +++ b/install.sh @@ -35,7 +35,7 @@ abort() { umask 027 -[ -n "$AXZSH" ] || AXZSH="$HOME/.axzsh" +[ -n "$AXZSH" ] || AXZSH="${ZDOTDIR:-$HOME}/.axzsh" export AXZSH S=$(dirname "$0") @@ -79,7 +79,12 @@ mkdir -p "$AXZSH/custom_themes" || abort ax_msg - "Linking ZSH startup files ..." -for f in ~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc; do +for f in \ + ${ZDOTDIR:-$HOME}/.zlogin \ + ${ZDOTDIR:-$HOME}/.zlogout \ + ${ZDOTDIR:-$HOME}/.zprofile \ + ${ZDOTDIR:-$HOME}/.zshrc \ +; do safe_rm "$f" || abort ln -sv "$AXZSH/ax.zsh" "$f" || abort done -- 2.39.2