From c217b57e690c188a28992f48d80e9885c962fac9 Mon Sep 17 00:00:00 2001 From: thek4n Date: Mon, 16 Dec 2024 11:58:52 +0300 Subject: [PATCH] zsh autoenv --- home/user/.config/zsh/other | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/home/user/.config/zsh/other b/home/user/.config/zsh/other index cc071de..f581e25 100644 --- a/home/user/.config/zsh/other +++ b/home/user/.config/zsh/other @@ -1,4 +1,6 @@ +# vim: ft=zsh + # enable color support of ls, less and man, and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" @@ -14,4 +16,28 @@ if [ -x /usr/bin/dircolors ]; then # Take advantage of $LS_COLORS for completion as well zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +fi + + + +_autoenv() { + if [ -f .env ]; then + . ./.env + fi +} + +_autoenv_leave() { + if [ -f "${OLDPWD}/.env.leave" ]; then + . "${OLDPWD}/.env.leave" + fi +} + +autoload -U add-zsh-hook + +add-zsh-hook chpwd _autoenv +add-zsh-hook chpwd _autoenv_leave + + +if [ -f .env ]; then + . ./.env fi \ No newline at end of file