summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2023-07-08 12:10:11 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2023-07-08 12:14:02 +0100
commitcdef6419b46d66747bb1edf324dc41223da87c14 (patch)
tree650dd2dadac3f412910d6f9917827a99a358c8fe
parent6d720a1be90d19f6a785bec09354fbcd2a1a47ad (diff)
zsh: Iterate through variants in source_if_exists
-rw-r--r--zsh/env11
-rw-r--r--zsh/login4
-rw-r--r--zsh/profile4
-rw-r--r--zsh/rc4
4 files changed, 10 insertions, 13 deletions
diff --git a/zsh/env b/zsh/env
index 5df08b1..cec4b06 100644
--- a/zsh/env
+++ b/zsh/env
@@ -5,7 +5,12 @@ dotfiles_root() {
}
source_if_exists() {
- [[ -f $(dotfiles_root)/$1 ]] && . $(dotfiles_root)/$1 || return 0
+ local prefix file
+ for prefix in ${UNAME} ${DOMAIN} ${HOST_SHORT} ${HOST}; do
+ file=$(dotfiles_root)/dotfiles-${prefix}/$1
+ [[ -f ${file} ]] && . ${file}
+ done
+ return 0
}
export HOST=${HOST:l}
@@ -18,6 +23,4 @@ esac
setopt EXTENDED_GLOB
-source_if_exists dotfiles-${UNAME}/zsh/env
-source_if_exists dotfiles-${DOMAIN}/zsh/env
-source_if_exists dotfiles-${HOST}/zsh/env
+source_if_exists zsh/env
diff --git a/zsh/login b/zsh/login
index 95f8137..76979c0 100644
--- a/zsh/login
+++ b/zsh/login
@@ -1,5 +1,3 @@
# -*- mode: shell-script -*-
-source_if_exists dotfiles-${UNAME}/zsh/login
-source_if_exists dotfiles-${DOMAIN}/zsh/login
-source_if_exists dotfiles-${HOST}/zsh/login
+source_if_exists zsh/login
diff --git a/zsh/profile b/zsh/profile
index 536502d..7c70bb4 100644
--- a/zsh/profile
+++ b/zsh/profile
@@ -15,6 +15,4 @@ if [[ -n ${TERM} ]]; then
stty -ixon
fi
-source_if_exists dotfiles-${UNAME}/zsh/profile
-source_if_exists dotfiles-${DOMAIN}/zsh/profile
-source_if_exists dotfiles-${HOST}/zsh/profile
+source_if_exists zsh/profile
diff --git a/zsh/rc b/zsh/rc
index 3eb4c13..51a226d 100644
--- a/zsh/rc
+++ b/zsh/rc
@@ -72,8 +72,6 @@ if [[ ${TERM_PROGRAM} != iTerm.app ]]; then
setopt PROMPT_SUBST
fi
-source_if_exists dotfiles-${UNAME}/zsh/rc
-source_if_exists dotfiles-${DOMAIN}/zsh/rc
-source_if_exists dotfiles-${HOST}/zsh/rc
+source_if_exists zsh/rc
compinit -d ${XDG_CACHE_HOME}/zsh/compdump