Created
April 3, 2018 16:06
-
-
Save dpryden/92a9a94ed21207bba549bbe7ac41ca9f to your computer and use it in GitHub Desktop.
toxin: Script for running python or shell commands inside a .tox environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run a command inside a Tox environment | |
if ! [[ -d .tox ]]; then | |
echo 'Cannot find .tox in this directory!' | |
exit 1 | |
fi | |
if [[ "$1" == '-e' ]]; then | |
toxenv="$2" | |
shift 2 | |
else | |
toxenv="$(cd .tox && echo py* | awk '{print $NF}')" | |
fi | |
toxdir="$(cd .tox && pwd)" | |
bindir="$toxdir/$toxenv/bin" | |
activate_script="$bindir/activate" | |
if ! [[ -f $activate_script ]]; then | |
printf 'Cannot find tox env "%s" in current directory!\n' "$toxenv" | |
exit 1 | |
fi | |
if [[ "$1" == "" ]]; then | |
PATH="$bindir:$PATH" /bin/bash --rcfile "$activate_script" | |
else | |
PATH="$bindir:$PATH" /bin/bash --rcfile "$activate_script" -c "$*" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment