summaryrefslogtreecommitdiff
path: root/zsh/env
blob: 74d96cded2c263b9a1eb921855e9c5a5625f78ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- mode: shell-script -*-

dotfiles_root() {
  echo ${${(%):-%x}:A:h:h}
}

source_if_exists() {
  [[ -f $(dotfiles_root)/$1 ]] && . $(dotfiles_root)/$1 || return 0
}

[[ ${HOST} =~ \\. ]] && export DOMAIN=${(j:.:)${(s:.:)HOST}[-2,-1]:l}
export HOST=${HOST:l}
case ${OSTYPE} in
  darwin*) export UNAME=darwin ;;
   linux*) export UNAME=linux  ;;
esac

setopt EXTENDED_GLOB
setopt REMATCH_PCRE

source_if_exists dotfiles-${UNAME}/zsh/env
source_if_exists dotfiles-${DOMAIN}/zsh/env
source_if_exists dotfiles-${HOST}/zsh/env