-
Notifications
You must be signed in to change notification settings - Fork 0
/
venv_wrapper.sh
56 lines (45 loc) · 966 Bytes
/
venv_wrapper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Taken from https://gist.github.com/dbtek/fb2ddccb18f0cf63a654ea2cc94c8f19
# usage
# $ mkvenv myvirtualenv # creates venv under ~/.venv/
# $ venv myvirtualenv # activates venv
# $ deactivate # deactivates venv
# $ rmvenv myvirtualenv # removes venv
export VENV_HOME="$HOME/.venv"
[[ -d $VENV_HOME ]] || mkdir $VENV_HOME
lsvenv() {
ls -1 $VENV_HOME
}
venv() {
if [ $# -eq 0 ]
then
echo "Please provide venv name"
else
source "$VENV_HOME/$1/bin/activate"
fi
}
mkvenv() {
if [ $# -eq 0 ]
then
echo "Please provide venv name"
else
python3 -m venv $VENV_HOME/$1
fi
}
rmvenv() {
if [ $# -eq 0 ]
then
echo "Please provide venv name"
else
rm -r $VENV_HOME/$1
fi
}
_script()
{
_script_commands=$(lsvenv)
local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) )
return 0
}
complete -o nospace -F _script venv