2a0c12d6fba10ffce4a5ad5b9ccade2858c548d4
[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 isdarwin(){
116 [[ $OSNAME == Darwin* ]] && return 0
117 return 1
118 }
119
120 isfreebsd(){
121 [[ $OSNAME == FreeBSD* ]] && return 0
122 return 1
123 }
124
125 if ! [[ ${ZSH_VERSION} == 3.1.<7->* \
126 || ${ZSH_VERSION} == 3.<2->.<->* \
127 || ${ZSH_VERSION} == <4->.<->* ]] ; then
128
129 printf '-!-\n'
130 printf '-!- In this configuration we try to only enable features supported by the shell\n'
131 printf '-!- version found on the system. However you are running a particular old zsh\n'
132 printf '-!- "version %s.\n' "$ZSH_VERSION"
133 printf '-!- While this *may* work, it might as well fail.\n'
134 printf '-!-\n'
135 printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n'
136 printf '-!-\n'
137 printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n'
138 printf '-!- If it does today, you'\''ve been lucky.\n'
139 printf '-!-\n'
140 printf '-!- Ye been warned!\n'
141 printf '-!-\n'
142
143 function zstyle() { : }
144 fi
145
146 for paths in "$fpath[@]"; do
147 for func in "$paths"/*(N:t); do
148 zrcautoload $func
149 done
150 done
151 unset paths