You can use ``autoenv-edit`` to edit the nearest/current autoenv files.
It will use ``$AUTOENV_EDITOR``, ``$EDITOR``, or ``vim`` for editing.
+## Helper functions
+
+The following helper functions are available:
+
+### autoenv_append_path
+
+Appends path(s) to `$path` (`$PATH`), if they are not in there already.
+
+### autoenv_prepend_path
+
+Prepends path(s) to `$path` (`$PATH`), if they are not in there already.
+
+### autoenv_remove_path
+
+Removes path(s) from `$path` (`$PATH`).
+
+Returns 0 in case `$path` has changed, 1 otherwise.
+
## Recipes
### Automatically activate Python virtualenvs
fi
}
+autoenv_append_path() {
+ local i
+ for i; do
+ (( ${path[(i)$i]} <= ${#path} )) && continue
+ path+=($i)
+ done
+}
+autoenv_prepend_path() {
+ local i
+ for i; do
+ (( ${path[(i)$i]} <= ${#path} )) && continue
+ path=($i $path)
+ done
+}
+autoenv_remove_path() {
+ local i
+ local old_path=$path
+ for i; do
+ path=("${(@)path:#$i}")
+ done
+ [[ $old_path != $path ]]
+}
+
# Internal functions. {{{
# Internal: stack of loaded env files (i.e. entered directories). {{{
typeset -g -a _autoenv_stack_entered
--- /dev/null
+Tests for provided utils/helpers.
+
+ $ source $TESTDIR/setup.zsh || return 1
+
+ $ PATH=
+ $ autoenv_prepend_path custom_path
+ $ echo $PATH
+ custom_path
+
+ $ autoenv_prepend_path custom_path
+ $ echo $PATH
+ custom_path
+
+ $ autoenv_prepend_path another_path a_third_one
+ $ echo $PATH
+ a_third_one:another_path:custom_path
+
+ $ autoenv_remove_path another_path a_third_one
+ $ echo $PATH
+ custom_path
+
+ $ autoenv_remove_path does_not_exist
+ [1]
+ $ echo $PATH
+ custom_path
+
+ $ autoenv_remove_path custom_path
+ $ echo PATH:$PATH
+ PATH: