From 46faf1536b880a613690991f79781e69a3f15311 Mon Sep 17 00:00:00 2001 From: thek4n Date: Mon, 16 Dec 2024 12:18:48 +0300 Subject: [PATCH] zsh autoenv authorized dirs --- home/user/.config/git/ignore | 1 + home/user/.config/zsh/other | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/home/user/.config/git/ignore b/home/user/.config/git/ignore index 0a78fa7..8ab624f 100644 --- a/home/user/.config/git/ignore +++ b/home/user/.config/git/ignore @@ -19,6 +19,7 @@ __pycache__/ *.log *.bak *~ +.env.leave # db *.db diff --git a/home/user/.config/zsh/other b/home/user/.config/zsh/other index f581e25..7d96a1a 100644 --- a/home/user/.config/zsh/other +++ b/home/user/.config/zsh/other @@ -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