summaryrefslogtreecommitdiff
path: root/.zsh/sourcedir
blob: d4c627fe11e6d4fdd2e09ffc730c08870e5c4919 (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
# sourcedir
#
# Defines helper function to source files in a directory
#
# Copyright © 1994-2008 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
# Source repository: git://git.madduck.net/etc/zsh.git
#

. $ZDOTDIR/logging

sourcedir() {
  if [ ! -d "$1" ]; then
    error "no such directory: $1"
    return 1
  fi

  for f in "$1"/*(.N,@N); do
    case "$f" in
      *~|*.bak|*.old|*.sw?|*.zwc|*.disabled) continue;;
    esac

    source "$f"
  done
}

# vim:ft=zsh