summaryrefslogtreecommitdiff
path: root/zshrc
blob: 158225ab8440107cb24a2189ca54f5d04b65b0f1 (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
26
27
28
29
# Determine location of this file from the assumption that
# it is linked to ~/.zshrc. This is required to find the
# config files and plugins located relative to this file

# directory this file is in
local CFG_DIR
if [ -z "$ZSH_CFG_DIR" ]; then
  CFG_DIR=$(dirname $(readlink -f "${(%):-%N}"))
else
  CFG_DIR="$ZSH_CFG_DIR"
fi

for plugin in $CFG_DIR/plugins/*(N); do
  # add *.zsh if no *.plugin.zsh found
  local files=( $plugin/*.plugin.zsh(N) )
  if [ ${#files[@]} -eq 0 ]; then
    files=( $plugin/*.zsh(N) )
  fi
  
  for file in $files; source $file
  fpath=($fpath $plugin)
done

fpath=($CFG_DIR/functions $fpath)
for fn in $CFG_DIR/functions/*(.N); autoload $(basename $fn)

for conf in $CFG_DIR/conf.d/*(.N); do
  source "$conf"
done