1
0
Fork 0

make autopyenv PS1 prettier

This commit is contained in:
Luca Bilke 2022-08-03 13:12:28 +02:00
parent bede9bf15a
commit 7a6813d980
No known key found for this signature in database
GPG Key ID: 7B77C51E8C779E75
1 changed files with 8 additions and 3 deletions

View File

@ -1,16 +1,21 @@
PYENV_DIR="${PYENVS_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/virtualenv}" PYENV_DIR="${PYENVS_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/virtualenv}"
function chpwd_activate(){ function chpwd_activate(){
[[ "$(pwd)" == "/" ]] && return 0 [[ "$(pwd)" == "/" ]] && return 0
envdir=$(pwd|sed -e s@/@_@g|cut -c2-)
for pydir in $(ls $PYENV_DIR); do for pydir in $(ls $PYENV_DIR); do
if [[ "$envdir" == "$pydir" ]]; then if [[ "$(pwd|sed -e s@/@_@g|cut -c2-)" =~ "^$pydir$" ]]; then
if [ "x$VIRTUAL_ENV" != "x$PYENV_DIR/$pydir" ]; then if [ "x$VIRTUAL_ENV" != "x$PYENV_DIR/$pydir" ]; then
export VIRTUAL_ENV_DISABLE_PROMPT=1
export PS1="$PS1"
source "$PYENV_DIR/$pydir/bin/activate" source "$PYENV_DIR/$pydir/bin/activate"
return return
fi fi
fi fi
done done
[[ "x$VIRTUAL_ENV" != "x" ]] && deactivate if [ "x$VIRTUAL_ENV" != "x" ]; then
unset VIRTUAL_ENV_DISABLE_PROMPT
export PS1="${PS1:3}"
deactivate
fi
} }
function venv-here(){ function venv-here(){