diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2023-07-08 12:10:11 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2023-07-08 12:14:02 +0100 |
| commit | cdef6419b46d66747bb1edf324dc41223da87c14 (patch) | |
| tree | 650dd2dadac3f412910d6f9917827a99a358c8fe | |
| parent | 6d720a1be90d19f6a785bec09354fbcd2a1a47ad (diff) | |
zsh: Iterate through variants in source_if_exists
| -rw-r--r-- | zsh/env | 11 | ||||
| -rw-r--r-- | zsh/login | 4 | ||||
| -rw-r--r-- | zsh/profile | 4 | ||||
| -rw-r--r-- | zsh/rc | 4 |
4 files changed, 10 insertions, 13 deletions
@@ -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 @@ -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 @@ -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 |
