Move into an external dir
[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 # Some things need to be done very early
32 # the following helper functions have been taken from the grml zshrc
33 # (wherever they got them from)
34 # check for version/system
35 # check for versions (compatibility reasons)
36 is4(){
37 [[ $ZSH_VERSION == <4->* ]] && return 0
38 return 1
39 }
40
41 is41(){
42 [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0
43 return 1
44 }
45
46 is42(){
47 [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
48 return 1
49 }
50
51 is425(){
52 [[ $ZSH_VERSION == 4.2.<5->* || $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
53 return 1
54 }
55
56 is43(){
57 [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
58 return 1
59 }
60
61 is433(){
62 [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* \
63 || $ZSH_VERSION == <5->* ]] && return 0
64 return 1
65 }
66
67 is434(){
68 [[ $ZSH_VERSION == 4.3.<4->* || $ZSH_VERSION == 4.<4->* \
69 || $ZSH_VERSION == <5->* ]] && return 0
70 return 1
71 }
72
73 is435(){
74 [[ $ZSH_VERSION == 4.3.<5->* || $ZSH_VERSION == 4.<4->* \
75 || $ZSH_VERSION == <5->* ]] && return 0
76 return 1
77 }
78
79 is437(){
80 [[ $ZSH_VERSION == 4.3.<7->* || $ZSH_VERSION == 4.<4->* \
81 || $ZSH_VERSION == <5->* ]] && return 0
82 return 1
83 }
84
85 is439(){
86 [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* \
87 || $ZSH_VERSION == <5->* ]] && return 0
88 return 1
89 }
90
91 is4311(){
92 [[ $ZSH_VERSION == 4.3.<11->* || $ZSH_VERSION == 4.<4->* \
93 || $ZSH_VERSION == <5->* ]] && return 0
94 return 1
95 }
96
97 isdarwin(){
98 [[ $OSNAME == Darwin* ]] && return 0
99 return 1
100 }
101
102 isfreebsd(){
103 [[ $OSNAME == FreeBSD* ]] && return 0
104 return 1
105 }
106
107 isutf8(){
108 [[ $(locale charmap) == "UTF-8" ]] && return 0
109 return 1
110 }
111
112 isconsole(){
113 [[ $TERM == "linux" ]] && return 0
114 return 1
115 }
116
117 if ! [[ ${ZSH_VERSION} == 3.1.<7->* \
118 || ${ZSH_VERSION} == 3.<2->.<->* \
119 || ${ZSH_VERSION} == <4->.<->* ]] ; then
120
121 printf '-!-\n'
122 printf '-!- In this configuration we try to only enable features supported by the shell\n'
123 printf '-!- version found on the system. However you are running a particular old zsh\n'
124 printf '-!- "version %s.\n' "$ZSH_VERSION"
125 printf '-!- While this *may* work, it might as well fail.\n'
126 printf '-!-\n'
127 printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n'
128 printf '-!-\n'
129 printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n'
130 printf '-!- If it does today, you'\''ve been lucky.\n'
131 printf '-!-\n'
132 printf '-!- Ye been warned!\n'
133 printf '-!-\n'
134
135 function zstyle() { : }
136 fi
137
138 # Now that FPATH is set correctly, do autoloaded functions.
139 # autoload all functions in $FPATH - that is, all files in
140 # each component of the array $fpath. If there are none, feed the list
141 # it prints into /dev/null.
142 for paths in "$fpath[@]"; do
143 autoload -U "$paths"/*(N:t) >/dev/null
144 done
145 unset paths