claytron / dotfiles

My *nix confs

This URL has Read+Write access

dotfiles / .zshenv
100644 107 lines (97 sloc) 2.703 kb
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
source $HOME/.commonenv
 
###################################
# Here we set the PATH: #
###################################
 
# from http://zsh.dotsrc.org/Contrib/startup/users/debbiep/dot.zshenv
# rationalize-path()
# Later we'll need to trim down the paths that follow because the ones
# given here are for all my accounts, some of which have unusual
# paths in them. rationalize-path will remove
# nonexistent directories from an array.
rationalize-path () {
  # Note that this works only on arrays, not colon-delimited strings.
  # Not that this is a problem now that there is typeset -T.
  local element
  local build
  build=()
  # Evil quoting to survive an eval and to make sure that
  # this works even with variables containing IFS characters, if I'm
  # crazy enough to setopt shwordsplit.
  eval '
  foreach element in "$'"$1"'[@]"
  do
    if [[ -d "$element" ]]
    then
      build=("$build[@]" "$element")
    fi
  done
  '"$1"'=( "$build[@]" )
  '
}
 
# Include function path in script path so that we can run them even
# though a subshell may not know about functions.
# PATH should already be exported, but in case not. . .
path=(
  "$HOME/bin/$MACHTYPE-$OSTYPE"
  "$HOME/bin"
  /opt/python-build/python-2.4/bin
  /opt/python/bin
  /opt/local/bin
  /opt/local/sbin
  /opt/local/lib/postgresql83/bin
  /opt/local/lib/mysql5/bin
  /opt/local/Library/Frameworks/Python.framework/Versions/2.4/bin
  /sw/bin
  /sw/sbin
  /usr/local/bin
  /usr/local/sbin
  /usr/local/etc
  /usr/bin/perlbin/vendor
  /usr/bin/perlbin/core
  /sbin
  /etc
  /bin
  /usr/bin
  /usr/sbin
  /usr/ucb
  /usr/bsd
  /usr/libexec
  /Developer/Tools
  /usr/X11R6/bin
  /usr/X11/bin
  /usr/bin/X11
  /usr/local/X11/bin
  /usr/local/contrib/lib/kde/bin
  /usr/local/tex/bin
  /usr/local/lib/zsh/scr
  /usr/local/games
  /usr/games
  "$path[@]"
)
 
# add the following to the above array to get functions as well:
# "$fpath[@]"
 
export PATH
# Only unique entries please.
typeset -U path
# Remove entries that don't exist on this system. Just for sanity's
# sake more than anything.
rationalize-path path
 
# only on OS X for now, messing with this causes issues
if [ $UNAME = "Darwin" ]; then
    # Now let's take care of the
    # function path
    #############################
    
    fpath=(
        /usr/share/zsh/site-functions
        /usr/share/zsh/4.3.4/functions
        /opt/local/share/zsh/4.3.10/functions
    )
    
    export FPATH
    # Only unique entries please.
    typeset -U fpath
    # Remove entries that don't exist on this system. Just for sanity's
    # sake more than anything.
    rationalize-path fpath
fi
 
# extra per environment settings
source $HOME/.zshenv_extras