Skip to content

Instantly share code, notes, and snippets.

@obar1
Created April 11, 2024 04:13
Show Gist options
  • Save obar1/212e4c778548f8bcdc6e9c1b05856f3f to your computer and use it in GitHub Desktop.
Save obar1/212e4c778548f8bcdc6e9c1b05856f3f to your computer and use it in GitHub Desktop.
venv auto cd handling for 0to100 folder
function venv_cd() {
# set -x
if [[ $PWD == */0to100* ]]; then
echo "0to100 folder..."
if [[ -d .venv ]]; then
if [[ "$VIRTUAL_ENV" == "$PWD/.venv" ]]; then
echo "using $VIRTUAL_ENV"
else
deactivate || true
source .venv/bin/activate
echo "new $VIRTUAL_ENV..."
fi
fi
fi
# set +x
}
PROMPT_COMMAND=venv_cd
@obar1
Copy link
Author

obar1 commented Apr 11, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment