-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzshenv
executable file
·46 lines (40 loc) · 1.47 KB
/
zshenv
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
# Purpose of zshenv:
# http://zsh.sourceforge.net/Intro/intro_3.html
# zshenv's are sourced on every shell
# lenkite's dotfiles zshenv does two things
# * Sourcers ~/.env if present. ~/.env must contain lines of the form name=value
# it exports corresponding environemnt variables. Ideally I would want this guy to also
# take care of setting these as windows environment variables by using a custom cygwin
# program that can invoke win32 api calls. But hey, atleast it works on *nix.
# * Looks for a ~/paths file that simply contains lines. Each line is tested to see if it
# is a path that exists. If so it is added ot $PATH.
envfile=~/.env
if [[ -f $envfile ]]; then
source $envfile
fi
# dirname $0 doesnt work for zshenv
if [[ -d ~/dotfiles ]]; then
export dotfiles=~/dotfiles
fi
if [[ -d ~/dev/dotfiles ]]; then
export dotfiles=~/dev/dotfiles
fi
# http://zsh.sourceforge.net/Guide/zshguide02.html#l24
typeset -U path
path+=( $dotfiles/scripts ~/bin )
pathsf=~/.paths
if [[ -f $pathsf ]]; then
#http://stackoverflow.com/questions/12651355/zsh-read-lines-from-file-into-array
zmodload zsh/mapfile
FLINES=( "${(f)mapfile[$pathsf]}" )
LIST="${mapfile[$pathsf]}" # Not required unless stuff uses it
integer POS=1 # Not required unless stuff uses it
integer SIZE=$#FLINES # Number of lines, not required unless stuff uses it
# setting path list sets PATH in zsh
path+=( $FLINES )
# echo $SIZE
# for ITEM in $FLINES; do
# echo $ITEM
# (( POS++ ))
# done
fi