]> gitweb.pimeys.fr Git - config-20-100.git/blob - .zsh/rc/base/05_early_functions
Ajout du zshrc, même s'il manque encore de commentaires etc.
[config-20-100.git] / .zsh / rc / base / 05_early_functions
1 # Zshrc function definitions
2
3
4 # {{{ check for version/system
5 # check for versions (compatibility reasons)
6 is439(){
7 [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] && return 0
8 return 1
9 }
10
11 #f1# are we running within an utf environment?
12 isutfenv() {
13 case "$LANG $CHARSET $LANGUAGE" in
14 *utf*) return 0 ;;
15 *UTF*) return 0 ;;
16 *) return 1 ;;
17 esac
18 }
19
20 # check for user, if not running as root set $SUDO to sudo
21 (( EUID != 0 )) && SUDO='sudo' || SUDO=''
22
23 # autoload wrapper - use this one instead of autoload directly
24 # We need to define this function as early as this, because autoloading
25 # 'is-at-least()' needs it.
26 function zrcautoload() {
27 emulate -L zsh
28 setopt extended_glob
29 local fdir ffile
30 local -i ffound
31
32 ffile=$1
33 (( found = 0 ))
34 for fdir in ${fpath} ; do
35 [[ -e ${fdir}/${ffile} ]] && (( ffound = 1 ))
36 done
37
38 (( ffound == 0 )) && return 1
39 autoload -U ${ffile} || return 1
40 return 0
41 }
42
43 # Load is-at-least() for more precise version checks
44 # Note that this test will *always* fail, if the is-at-least
45 # function could not be marked for autoloading.
46 zrcautoload is-at-least || is-at-least() { return 1 }
47
48 # }}}