Skip to content

Commit 440ae55

Browse files
author
Basask
committed
Add command pyenvcmd
1 parent 023c918 commit 440ae55

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pyenvcmd

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# This commands lists your python virtualenvs, activate the selected one and runs an command on it
4+
5+
env="${PYENV_ROOT:?Please set your PYENV_ROOT env variable before running $0}"
6+
7+
cd "$env/versions"
8+
9+
# TODO: refac this to handle possible spaces in virtualenv names
10+
envs=(`find . -maxdepth 1 -type l -exec basename {} \;`)
11+
12+
for i in "${!envs[@]}"; do
13+
printf "%s\t%s\n" "$i" "${envs[$i]}"
14+
done
15+
16+
read -r -p "Environment id:" choose
17+
18+
env="${envs[$choose]}"
19+
20+
cd - >> /dev/null
21+
22+
printf "(%s)" "$env"
23+
24+
pyenv activate $env
25+
26+
$*
27+
28+
pyenv deactivate

0 commit comments

Comments
 (0)