Compare commits

..

1 Commits

Author SHA1 Message Date
7b549f01e5 Add autoenv, automatic environment setup
Using a hook, automatically detect when `.enter` and `.exit` scripts
and source them when changing the shells current directory.
2018-04-22 19:03:39 +01:00

View File

@ -66,8 +66,8 @@ _autoenv_exit() {
_autoenv_entered[${_autoenv_entered[(i)$entered]}]=()
}
# Find a directory containing a .enter file by searching up the directory tree
# starting in the current directory.
# Find all directories containing a .enter file by searching up the directory
# tree starting in the current directory.
_autoenv_find_enter_directories() {
local current=$PWD
# If an enter script is found in the current directory, return it.
@ -78,7 +78,8 @@ _autoenv_find_enter_directories() {
local next=$current/..; local next=${next:A}
# If an enter script is found in the current directory, return it.
[ -f $next/.enter ] && echo $next
# If the current directory equals the next directory, return.
# If the current directory equals the next directory we are done, otherwise
# update the current directory.
[[ $current == $next ]] && return || local current=$next
done
}