diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2011-03-08 10:58:05 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2011-03-08 10:58:41 +0100 |
commit | 8518370e6c116c6f914961e3f52050ca3035ab44 (patch) | |
tree | f1fef4c53a913a37c9d97eb78495c14360b5daf2 | |
parent | 8664c9bbef31bbca33be27731efe7634bf260836 (diff) |
add utility functions
-rw-r--r-- | .zsh/utils | 30 | ||||
-rw-r--r-- | .zsh/zstub | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/.zsh/utils b/.zsh/utils new file mode 100644 index 0000000..fd81acd --- /dev/null +++ b/.zsh/utils @@ -0,0 +1,30 @@ +# utils +# +# utility functions +# +# Copyright © 2011 Tobias Klauser <tklauser@distanz.ch> +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: git://git.distanz.ch/dotfiles/zsh.git + +# are we root? +is_root() { + test ${EUID:?} -eq 0 +} + +# are we on Mac OS X? +is_darwin() { + [[ $OSTYPE == darwin* ]] && return 0 + return 1 +} + +# are we running within an utf environment? +is_utfenv() { + case "$LANG $CHARSET $LANGUAGE" in + *utf*) return 0 ;; + *UTF*) return 0 ;; + *) return 1 ;; + esac +} + +# vim:ft=zsh @@ -11,6 +11,7 @@ source $ZDOTDIR/logging source $ZDOTDIR/sourcedir +source $ZDOTDIR/utils _DIR=$ZDOTDIR/${${(%):-%1N}#.} sourcedir $_DIR |