Skip to content

Commit

Permalink
inve += -h option
Browse files Browse the repository at this point in the history
  • Loading branch information
awdeorio committed Sep 11, 2023
1 parent 096b818 commit d99fd6c
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions bin/inve
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@
#
# inve
#
# usage: inve [VIRTUAL_ENV]
# Activate a virtual environment in a subshell.
#
# Attempts to find the root of a virtual environment by walking the directory
# tree from "$PWD" to "/". Then, it activates a subshell.
# Search up for common virtual environment names. Activate in a subshell when
# one is found. Otherwise, offer to create one.
#
# Andrew DeOrio <awdeorio@umich.edu>

# Virtual environment search path, basenames only, space separated
VENVPATH=".venv venv env"

# Stop on errors
set -Eeuo pipefail
set -Eeo pipefail

# Virtual environment search path, basenames only, space separated
VENVPATH=".venv venv env"
# Help
if [ "$1" == "-h" ]; then
echo "Usage: $0 [VIRTUAL_ENV]"
echo ""
echo "Activate a virtual environment in a subshell."
echo
echo "EXAMPLES:"
echo " inve Search up for virtual env then activate or create"
echo " inve VENV Activate or create virtual env VENV"
exit
fi

# Parse virtual env specified as an arg
VIRTUAL_ENV=""
if [ -n "${1-}" ]; then
# Virtual environment root specified as argument
VIRTUAL_ENV="$1"
else
# Search from PWD to root, for any of the virtual env directory names
fi

# Search for virtual environment from PWD to root
if [ -z "$VIRTUAL_ENV" ]; then
INVE_OLDPWD="$PWD"
while [ "${PWD}" != "/" ]; do
for VENV_BASENAME in ${VENVPATH}; do
Expand Down

0 comments on commit d99fd6c

Please sign in to comment.