zsh autoenv refactor
This commit is contained in:
parent
46faf1536b
commit
76568fa286
42
home/user/.config/zsh/autoenv
Normal file
42
home/user/.config/zsh/autoenv
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
# vim: ft=zsh
|
||||||
|
|
||||||
|
_autoenv() {
|
||||||
|
if [ -z "${PWD}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep "${PWD}" ~/.autoenv_authorized_dirs &>/dev/null; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f .env ]; then
|
||||||
|
source ./.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
|
||||||
|
source "${OLDPWD}/.env.leave"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
|
||||||
|
add-zsh-hook chpwd _autoenv
|
||||||
|
add-zsh-hook chpwd _autoenv_leave
|
||||||
|
|
||||||
|
|
||||||
|
if [ -f .env ]; then
|
||||||
|
if grep "${PWD}" ~/.autoenv_authorized_dirs &>/dev/null; then
|
||||||
|
. ./.env
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@ -17,43 +17,3 @@ if [ -x /usr/bin/dircolors ]; then
|
|||||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||||
fi
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
|
||||||
|
|
||||||
add-zsh-hook chpwd _autoenv
|
|
||||||
add-zsh-hook chpwd _autoenv_leave
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f .env ]; then
|
|
||||||
. ./.env
|
|
||||||
fi
|
|
||||||
@ -29,6 +29,8 @@ _so "${ZDOTDIR}/hosts/${HOST}"
|
|||||||
|
|
||||||
source "${ZDOTDIR}/plugin"
|
source "${ZDOTDIR}/plugin"
|
||||||
|
|
||||||
|
source "${ZDOTDIR}/autoenv"
|
||||||
|
|
||||||
source "${ZDOTDIR}/mappings"
|
source "${ZDOTDIR}/mappings"
|
||||||
|
|
||||||
source "${ZDOTDIR}/accept_line"
|
source "${ZDOTDIR}/accept_line"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user