summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2011-03-08 10:58:05 +0100
committerTobias Klauser <tklauser@distanz.ch>2011-03-08 10:58:41 +0100
commit8518370e6c116c6f914961e3f52050ca3035ab44 (patch)
treef1fef4c53a913a37c9d97eb78495c14360b5daf2
parent8664c9bbef31bbca33be27731efe7634bf260836 (diff)
add utility functions
-rw-r--r--.zsh/utils30
-rw-r--r--.zsh/zstub1
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
diff --git a/.zsh/zstub b/.zsh/zstub
index d0c994f..e8da803 100644
--- a/.zsh/zstub
+++ b/.zsh/zstub
@@ -11,6 +11,7 @@
source $ZDOTDIR/logging
source $ZDOTDIR/sourcedir
+source $ZDOTDIR/utils
_DIR=$ZDOTDIR/${${(%):-%1N}#.}
sourcedir $_DIR