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

source_if_exists() {
  [[ -f ${${(%):-%x}:A:h:h}/$1 ]] && . ${${(%):-%x}:A:h:h}/$1 || return 0
}

export DOMAIN=${$(cut -d. -f2- -s <<<${HOST}):l}
export HOST=${HOST:l}
export UNAME=${$(uname):l}

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

() {
  local dir
  for dir in ~/{.local/bin,bin} ${GOPATH:-~/go}/bin; do
    if [[ -d ${dir} && ${path[(I)${dir}]} -eq 0 ]]; then
      path=(${dir} ${path})
    fi
  done
}