diff options
l--------- | .zsh/.zshenv | 1 | ||||
-rw-r--r-- | .zsh/logging | 44 | ||||
-rw-r--r-- | .zsh/sourcedir | 28 | ||||
-rw-r--r-- | .zsh/zstub | 19 |
4 files changed, 92 insertions, 0 deletions
diff --git a/.zsh/.zshenv b/.zsh/.zshenv new file mode 120000 index 0000000..301876b --- /dev/null +++ b/.zsh/.zshenv @@ -0,0 +1 @@ +zstub
\ No newline at end of file diff --git a/.zsh/logging b/.zsh/logging new file mode 100644 index 0000000..49de37f --- /dev/null +++ b/.zsh/logging @@ -0,0 +1,44 @@ +# logging +# +# Logging abilities for the shell initialisation scripts +# +# Copyright © 1994-2008 martin f. krafft <madduck@madduck.net> +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: git://git.madduck.net/etc/zsh.git +# + +__log() { + local level; level="$1"; shift + echo "${level}: $@" >&2 +} + +__do_debug() { + [ -n "${ZDEBUG:-}" ] +} + +error() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log E "$@" + [ "${__XTRACE:-}" ] && set -x +} + +warn() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log W "$@" + [ "${__XTRACE:-}" ] && set -x +} + +info() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log I "$@" + [ "${__XTRACE:-}" ] && set -x +} + +debug() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __do_debug && __log D "$@" + [ "${__XTRACE:-}" ] && set -x +} + +# vim:ft=zsh diff --git a/.zsh/sourcedir b/.zsh/sourcedir new file mode 100644 index 0000000..d4c627f --- /dev/null +++ b/.zsh/sourcedir @@ -0,0 +1,28 @@ +# sourcedir +# +# Defines helper function to source files in a directory +# +# Copyright © 1994-2008 martin f. krafft <madduck@madduck.net> +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: git://git.madduck.net/etc/zsh.git +# + +. $ZDOTDIR/logging + +sourcedir() { + if [ ! -d "$1" ]; then + error "no such directory: $1" + return 1 + fi + + for f in "$1"/*(.N,@N); do + case "$f" in + *~|*.bak|*.old|*.sw?|*.zwc|*.disabled) continue;; + esac + + source "$f" + done +} + +# vim:ft=zsh diff --git a/.zsh/zstub b/.zsh/zstub new file mode 100644 index 0000000..d0c994f --- /dev/null +++ b/.zsh/zstub @@ -0,0 +1,19 @@ +# zstub +# +# Stub for all .z* files; actual content comes from a directory +# +# Copyright © 2011 Tobias Klauser <tklauser@distanz.ch> +# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net> +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: git://git.distanz.ch/dotfiles/zsh.git +# + +source $ZDOTDIR/logging +source $ZDOTDIR/sourcedir + +_DIR=$ZDOTDIR/${${(%):-%1N}#.} +sourcedir $_DIR +unset _DIR + +# vim:ft=zsh |