use setvar and respect settings as given in zshenv.local
[zsh.git] / .zsh / 00_Basics.zsh
1 # -*- mode: sh;-*-
2
3 # No core dumps
4 ulimit -c 0
5
6 # Tiny helper function to set variables/values according to styles
7 # removed after config load
8 setvar () {
9 variable=$1
10 default=$2
11 command=${3:-0}
12
13 local tempvar
14 zstyle -s ':ganneff:config' ${variable} tempvar
15 tempvar=${tempvar:-${default}}
16 if (( ${command} )); then
17 ${variable} ${tempvar}
18 else
19 export ${variable}=${tempvar}
20 fi
21 }
22
23 setvar umask 022 1
24
25 # Want a halfway sane terminal
26 [[ -t 0 ]] && /bin/stty erase "^H" intr "^C" susp "^Z" dsusp "^Y" stop "^S" start "^Q" kill "^U" >& /dev/null
27
28 # watch for everybody but me
29 watch=(notme)
30 # check every 5 min for login/logout activity
31 setvar LOGCHECK 302
32 setvar WATCHFMT '%n %a %l from %m at %t.'
33
34 # autoload wrapper - use this one instead of autoload directly
35 # We need to define this function as early as this, because autoloading
36 # 'is-at-least()' needs it.
37 zrcautoload() {
38 emulate -L zsh
39 setopt extended_glob
40 local fdir ffile
41 local -i ffound
42
43 ffile=$1
44 (( ffound = 0 ))
45 for fdir in ${fpath} ; do
46 [[ -e ${fdir}/${ffile} ]] && (( ffound = 1 ))
47 done
48
49 (( ffound == 0 )) && return 1
50 if [[ $ZSH_VERSION == 3.1.<6-> || $ZSH_VERSION == <4->* ]] ; then
51 autoload -U ${ffile} || return 1
52 else
53 autoload ${ffile} || return 1
54 fi
55 return 0
56 }
57
58 # Some things need to be done very early
59 # the following helper functions have been taken from the grml zshrc
60 # (wherever they got them from)
61 # check for version/system
62 # check for versions (compatibility reasons)
63 is4(){
64 [[ $ZSH_VERSION == <4->* ]] && return 0
65 return 1
66 }
67
68 is41(){
69 [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0
70 return 1
71 }
72
73 is42(){
74 [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
75 return 1
76 }
77
78 is425(){
79 [[ $ZSH_VERSION == 4.2.<5->* || $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
80 return 1
81 }
82
83 is43(){
84 [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
85 return 1
86 }
87
88 is433(){
89 [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* \
90 || $ZSH_VERSION == <5->* ]] && return 0
91 return 1
92 }
93
94 is434(){
95 [[ $ZSH_VERSION == 4.3.<4->* || $ZSH_VERSION == 4.<4->* \
96 || $ZSH_VERSION == <5->* ]] && return 0
97 return 1
98 }
99
100 is435(){
101 [[ $ZSH_VERSION == 4.3.<5->* || $ZSH_VERSION == 4.<4->* \
102 || $ZSH_VERSION == <5->* ]] && return 0
103 return 1
104 }
105
106 is437(){
107 [[ $ZSH_VERSION == 4.3.<7->* || $ZSH_VERSION == 4.<4->* \
108 || $ZSH_VERSION == <5->* ]] && return 0
109 return 1
110 }
111
112 is439(){
113 [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* \
114 || $ZSH_VERSION == <5->* ]] && return 0
115 return 1
116 }
117
118 isdarwin(){
119 [[ $OSNAME == Darwin* ]] && return 0
120 return 1
121 }
122
123 isfreebsd(){
124 [[ $OSNAME == FreeBSD* ]] && return 0
125 return 1
126 }
127
128 if ! [[ ${ZSH_VERSION} == 3.1.<7->* \
129 || ${ZSH_VERSION} == 3.<2->.<->* \
130 || ${ZSH_VERSION} == <4->.<->* ]] ; then
131
132 printf '-!-\n'
133 printf '-!- In this configuration we try to only enable features supported by the shell\n'
134 printf '-!- version found on the system. However you are running a particular old zsh\n'
135 printf '-!- "version %s.\n' "$ZSH_VERSION"
136 printf '-!- While this *may* work, it might as well fail.\n'
137 printf '-!-\n'
138 printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n'
139 printf '-!-\n'
140 printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n'
141 printf '-!- If it does today, you'\''ve been lucky.\n'
142 printf '-!-\n'
143 printf '-!- Ye been warned!\n'
144 printf '-!-\n'
145
146 function zstyle() { : }
147 fi
148
149 for paths in "$fpath[@]"; do
150 for func in "$paths"/*(N:t); do
151 zrcautoload $func
152 done
153 done
154 unset paths