Enable tracing of the initialization
[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 # watch for everybody but me
26 watch=(notme)
27 # check every 5 min for login/logout activity
28 setvar LOGCHECK 302
29 setvar WATCHFMT '%n %a %l from %m at %t.'
30
31 # autoload wrapper - use this one instead of autoload directly
32 # We need to define this function as early as this, because autoloading
33 # 'is-at-least()' needs it.
34 zrcautoload() {
35 emulate -L zsh
36 setopt extended_glob
37 local fdir ffile
38 local -i ffound
39
40 ffile=$1
41 (( ffound = 0 ))
42 for fdir in ${fpath} ; do
43 [[ -e ${fdir}/${ffile} ]] && (( ffound = 1 ))
44 done
45
46 (( ffound == 0 )) && return 1
47 if [[ $ZSH_VERSION == 3.1.<6-> || $ZSH_VERSION == <4->* ]] ; then
48 autoload -U ${ffile} || return 1
49 else
50 autoload ${ffile} || return 1
51 fi
52 return 0
53 }
54
55 # Some things need to be done very early
56 # the following helper functions have been taken from the grml zshrc
57 # (wherever they got them from)
58 # check for version/system
59 # check for versions (compatibility reasons)
60 is4(){
61 [[ $ZSH_VERSION == <4->* ]] && return 0
62 return 1
63 }
64
65 is41(){
66 [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0
67 return 1
68 }
69
70 is42(){
71 [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
72 return 1
73 }
74
75 is425(){
76 [[ $ZSH_VERSION == 4.2.<5->* || $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
77 return 1
78 }
79
80 is43(){
81 [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
82 return 1
83 }
84
85 is433(){
86 [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* \
87 || $ZSH_VERSION == <5->* ]] && return 0
88 return 1
89 }
90
91 is434(){
92 [[ $ZSH_VERSION == 4.3.<4->* || $ZSH_VERSION == 4.<4->* \
93 || $ZSH_VERSION == <5->* ]] && return 0
94 return 1
95 }
96
97 is435(){
98 [[ $ZSH_VERSION == 4.3.<5->* || $ZSH_VERSION == 4.<4->* \
99 || $ZSH_VERSION == <5->* ]] && return 0
100 return 1
101 }
102
103 is437(){
104 [[ $ZSH_VERSION == 4.3.<7->* || $ZSH_VERSION == 4.<4->* \
105 || $ZSH_VERSION == <5->* ]] && return 0
106 return 1
107 }
108
109 is439(){
110 [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* \
111 || $ZSH_VERSION == <5->* ]] && return 0
112 return 1
113 }
114
115 is4311(){
116 [[ $ZSH_VERSION == 4.3.<11->* || $ZSH_VERSION == 4.<4->* \
117 || $ZSH_VERSION == <5->* ]] && return 0
118 return 1
119 }
120
121 isdarwin(){
122 [[ $OSNAME == Darwin* ]] && return 0
123 return 1
124 }
125
126 isfreebsd(){
127 [[ $OSNAME == FreeBSD* ]] && return 0
128 return 1
129 }
130
131 if ! [[ ${ZSH_VERSION} == 3.1.<7->* \
132 || ${ZSH_VERSION} == 3.<2->.<->* \
133 || ${ZSH_VERSION} == <4->.<->* ]] ; then
134
135 printf '-!-\n'
136 printf '-!- In this configuration we try to only enable features supported by the shell\n'
137 printf '-!- version found on the system. However you are running a particular old zsh\n'
138 printf '-!- "version %s.\n' "$ZSH_VERSION"
139 printf '-!- While this *may* work, it might as well fail.\n'
140 printf '-!-\n'
141 printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n'
142 printf '-!-\n'
143 printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n'
144 printf '-!- If it does today, you'\''ve been lucky.\n'
145 printf '-!-\n'
146 printf '-!- Ye been warned!\n'
147 printf '-!-\n'
148
149 function zstyle() { : }
150 fi
151
152 for paths in "$fpath[@]"; do
153 for func in "$paths"/*(N:t); do
154 zrcautoload $func
155 done
156 done
157 unset paths