X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=.zsh%2Frc%2Fbase%2F05_early_functions;fp=.zsh%2Frc%2Fbase%2F05_early_functions;h=04e9a89bc2a216ae28cefac444abfbb83005a48f;hb=3d71eab53c5b63556363ece880859b0af7f162da;hp=0000000000000000000000000000000000000000;hpb=1f8b08895681d46802368eec0764ca70d08898ca;p=config-20-100.git diff --git a/.zsh/rc/base/05_early_functions b/.zsh/rc/base/05_early_functions new file mode 100644 index 0000000..04e9a89 --- /dev/null +++ b/.zsh/rc/base/05_early_functions @@ -0,0 +1,48 @@ +# Zshrc function definitions + + +# {{{ check for version/system +# check for versions (compatibility reasons) +is439(){ + [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] && return 0 + return 1 +} + +#f1# are we running within an utf environment? +isutfenv() { + case "$LANG $CHARSET $LANGUAGE" in + *utf*) return 0 ;; + *UTF*) return 0 ;; + *) return 1 ;; + esac +} + +# check for user, if not running as root set $SUDO to sudo +(( EUID != 0 )) && SUDO='sudo' || SUDO='' + +# autoload wrapper - use this one instead of autoload directly +# We need to define this function as early as this, because autoloading +# 'is-at-least()' needs it. +function zrcautoload() { + emulate -L zsh + setopt extended_glob + local fdir ffile + local -i ffound + + ffile=$1 + (( found = 0 )) + for fdir in ${fpath} ; do + [[ -e ${fdir}/${ffile} ]] && (( ffound = 1 )) + done + + (( ffound == 0 )) && return 1 + autoload -U ${ffile} || return 1 + return 0 +} + +# Load is-at-least() for more precise version checks +# Note that this test will *always* fail, if the is-at-least +# function could not be marked for autoloading. +zrcautoload is-at-least || is-at-least() { return 1 } + +# }}}