From 1375ee2f3cba0fc4a0f32fce476433bbfac31446 Mon Sep 17 00:00:00 2001 From: "Alexander Gehrke (crater2150)" Date: Mon, 18 Mar 2013 13:25:38 +0100 Subject: [PATCH] README file (and some fixes) --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++ env_template | 2 -- modules/loader.zsh | 6 ++++-- zprofile | 8 ++++---- 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..aaf012c --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +crater's zsh config +=================== + +Installation: +------------- + +*system-wide config*: Put repository contents in `/etc/zsh`. + +*user config*: copy `env_template` to $HOME/.zshenv. Change value of `$ZDOTDIR` in +that file to the path, where the repository resides. +Note that this file is read before any other config files, so if any variables +you set in there have wrong values, they are probably overwritten in another +file. + +modules: +-------- + +This zsh configuration is modular. A module consists of a folder in the modules/ +directory, containing a script file named `init` and an optional `depend` file. +More files may be included in the folder, they will be ignored by the module +loader. The name of the module is the name of its directory. + +The `init` file is executed, when a module is loaded. When and if a module is +loaded is determined by its `depend` file and the environment variables +`$ZMODLOAD_ONLY` and `$ZMODLOAD_BLACKLIST`. + +`$ZMODLOAD_BLACKLIST` is a list of modules, that will not be loaded. + +`$ZMODLOAD_ONLY` works as a whitelist. If it is set, only modules in this list +and modules required by them will be loaded. + +A `depend` file contains the requirements for loading a module. It should +contain lines of the form ` `. There are 3 types for +dependencies: + + - `depend `: `` will be loaded before the depending + module (the module whose `depend` file contains this rule), regardless + of `$ZMODLOAD_ONLY`. If the module is blacklisted, it and the depending + module are not loaded. Note that already queued dependencies of the depending + module will be loaded anyways. + + - `after `: `` will be loaded before the depending + module, if it would be loaded anyways. If it is either blacklisted or + `$ZMODLOAD_ONLY` is non-empty but does not contain ``, it is not + loaded. This does not affect loading of the depending module. + + - `block `: abort loading of the depending module, if `` + is already loaded or contained in `$ZMODLOAD_ONLY`. diff --git a/env_template b/env_template index de3fcee..485adbe 100644 --- a/env_template +++ b/env_template @@ -1,7 +1,5 @@ export ZDOTDIR="$HOME/.zsh" PROMPT_UNICODE=yes -LANG=en_US.UTF-8 -export LANG zcpath="$ZDOTDIR" # on foreign server I don't want to accidentaly alarm admins diff --git a/modules/loader.zsh b/modules/loader.zsh index 6bed824..a579a5a 100644 --- a/modules/loader.zsh +++ b/modules/loader.zsh @@ -76,6 +76,7 @@ mod_deps() { while read relation dep; do mod_check_dep $modpath $relation $dep + [ $? -gt 0 ] && return $?; done < "$modpath/depend" return 0; } @@ -103,8 +104,9 @@ mod_check_dep() { fi ;; "after") - if [ -z "$ZMODLOAD_ONLY" ] \ - || in_array "$dep" "${(@)ZMODLOAD_ONLY}"; then + if ([ -z "$ZMODLOAD_ONLY" ] \ + || in_array "$dep" "${(@)ZMODLOAD_ONLY}") + && ! in_array "$dep" "${(@)ZMODLOAD_BLACKLIST}"; then mod_queue "$dep" is_dep ${modpath}; fi ;; "block") diff --git a/zprofile b/zprofile index 1a136ae..acc4124 100644 --- a/zprofile +++ b/zprofile @@ -3,6 +3,10 @@ if [ -e /etc/profile.env ] ; then . /etc/profile.env fi +for sh in /etc/profile.d/*.sh ; do + [ -r "$sh" ] && . "$sh" +done + if [ -e "$HOME/.profile" ]; then . "$HOME/.profile" fi @@ -24,10 +28,6 @@ unset ROOTPATH shopts=$- setopt nullglob -#more gentoo specific stuff -for sh in /etc/profile.d/*.sh ; do - [ -r "$sh" ] && . "$sh" -done unsetopt nullglob set -$shopts