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