59 lines
1.4 KiB
Bash

# 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)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
# 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 [ -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