drop function keyword
[zsh.git] / .zsh / 00_Basics.zsh
1 # -*- mode: sh;-*-
2
3 # No core dumps
4 ulimit -c 0
5
6 local _umask
7 zstyle -s ':ganneff:config' umask _umask
8 _umask=${_umask:-022}
9 umask $_umask
10 # Tiny helper function to set variables/values according to styles
11 # removed after config load
12 setvar () {
13 variable=$1
14 default=$2
15 command=${3:-0}
16
17 local tempvar
18 zstyle -s ':ganneff:config' ${variable} tempvar
19 tempvar=${tempvar:-${default}}
20 if (( ${command} )); then
21 ${variable} ${tempvar}
22 else
23 export ${variable}=${tempvar}
24 fi
25 }
26
27
28 # Want a halfway sane terminal
29 [[ -t 0 ]] && /bin/stty erase "^H" intr "^C" susp "^Z" dsusp "^Y" stop "^S" start "^Q" kill "^U" >& /dev/null
30
31 # watch for everybody but me
32 watch=(notme)
33 # check every 5 min for login/logout activity
34 LOGCHECK=300
35 WATCHFMT='%n %a %l from %m at %t.'
36
37 # autoload wrapper - use this one instead of autoload directly
38 # We need to define this function as early as this, because autoloading
39 # 'is-at-least()' needs it.
40 zrcautoload() {
41 emulate -L zsh
42 setopt extended_glob
43 local fdir ffile
44 local -i ffound
45
46 ffile=$1
47 (( ffound = 0 ))
48 for fdir in ${fpath} ; do
49 [[ -e ${fdir}/${ffile} ]] && (( ffound = 1 ))
50 done
51
52 (( ffound == 0 )) && return 1
53 if [[ $ZSH_VERSION == 3.1.<6-> || $ZSH_VERSION == <4->* ]] ; then
54 autoload -U ${ffile} || return 1
55 else
56 autoload ${ffile} || return 1
57 fi
58 return 0
59 }
60
61 # Some things need to be done very early
62 # the following helper functions have been taken from the grml zshrc
63 # (wherever they got them from)
64 # check for version/system
65 # check for versions (compatibility reasons)
66 is4(){
67 [[ $ZSH_VERSION == <4->* ]] && return 0
68 return 1
69 }
70
71 is41(){
72 [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0
73 return 1
74 }
75
76 is42(){
77 [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
78 return 1
79 }
80
81 is425(){
82 [[ $ZSH_VERSION == 4.2.<5->* || $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
83 return 1
84 }
85
86 is43(){
87 [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
88 return 1
89 }
90
91 is433(){
92 [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* \
93 || $ZSH_VERSION == <5->* ]] && return 0
94 return 1
95 }
96
97 is434(){
98 [[ $ZSH_VERSION == 4.3.<4->* || $ZSH_VERSION == 4.<4->* \
99 || $ZSH_VERSION == <5->* ]] && return 0
100 return 1
101 }
102
103 is435(){
104 [[ $ZSH_VERSION == 4.3.<5->* || $ZSH_VERSION == 4.<4->* \
105 || $ZSH_VERSION == <5->* ]] && return 0
106 return 1
107 }
108
109 is437(){
110 [[ $ZSH_VERSION == 4.3.<7->* || $ZSH_VERSION == 4.<4->* \
111 || $ZSH_VERSION == <5->* ]] && return 0
112 return 1
113 }
114
115 is439(){
116 [[ $ZSH_VERSION == 4.3.<9->* || $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