30 lines
1.1 KiB
Plaintext
30 lines
1.1 KiB
Plaintext
ARCH=`uname -m`
|
|
if [[ $ARCH == "arm64" ]]; then
|
|
PREFIX="/opt/homebrew"
|
|
else
|
|
PREFIX="/usr/local"
|
|
fi
|
|
|
|
export WORKON_HOME=~/python-envs
|
|
export VIRTUALENVWRAPPER_VIRTUALENV=$PREFIX/bin/virtualenv
|
|
mkdir -p $WORKON_HOME
|
|
source $PREFIX/bin/virtualenvwrapper.sh
|
|
|
|
# NOTE: an inherited VIRTUAL_ENV is *not* re-activated here — that happens at the
|
|
# very end of .zshrc so activate captures the fully-built PATH (see the comment
|
|
# there). Sourcing virtualenvwrapper.sh above only defines workon/deactivate/etc.
|
|
|
|
# Mirror the current venv into a per-pane tmux option so that splitting a pane
|
|
# can carry it into the new pane (.tmux.conf reads #{@venv} with `-e`). Per-pane
|
|
# (not session) state is what lets two panes hold different venvs and lets new
|
|
# *windows* start clean. Only fork tmux when the value actually changes.
|
|
_venv_track_precmd() {
|
|
[[ -n $TMUX ]] || return
|
|
if [[ "${VIRTUAL_ENV:-}" != "${_LAST_TRACKED_VENV-unset}" ]]; then
|
|
tmux set -p @venv "${VIRTUAL_ENV:-}" 2>/dev/null
|
|
_LAST_TRACKED_VENV="${VIRTUAL_ENV:-}"
|
|
fi
|
|
}
|
|
autoload -Uz add-zsh-hook
|
|
add-zsh-hook precmd _venv_track_precmd
|