zsh autoenv authorized dirs

This commit is contained in:
thek4n 2024-12-16 12:18:48 +03:00
parent c217b57e69
commit 46faf1536b
2 changed files with 17 additions and 0 deletions

View File

@ -19,6 +19,7 @@ __pycache__/
*.log
*.bak
*~
.env.leave
# db
*.db

View File

@ -21,12 +21,28 @@ fi
_autoenv() {
if [ -z "${PWD}" ]; then
return
fi
if ! grep "${PWD}" ~/.autoenv_authorized_dirs &>/dev/null; then
return
fi
if [ -f .env ]; then
. ./.env
fi
}
_autoenv_leave() {
if [ -z "${OLDPWD}" ]; then
return
fi
if ! grep "${OLDPWD}" ~/.autoenv_authorized_dirs &>/dev/null; then
return
fi
if [ -f "${OLDPWD}/.env.leave" ]; then
. "${OLDPWD}/.env.leave"
fi