Restructuring the repo
This commit is contained in:
parent
21e3cf65e6
commit
3d67598c27
45 changed files with 368 additions and 77 deletions
55
misc/venv
Executable file
55
misc/venv
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/zsh
|
||||
|
||||
zparseopts -D -E c=cdhere -cdvenv=cdvenv h=help -help=help n=newvenv -new=newvenv t=tmsu -tmsu=tmsu
|
||||
if [[ -n $help ]]; then
|
||||
<<-HELP
|
||||
Usage: ${0:t} [-c] [DIR]
|
||||
${0:t} -t
|
||||
|
||||
If DIR contains bin/activate, start a shell with that virtualenv.
|
||||
Otherwise recursively look up virtualenvs in DIR (by looking for dirs ending
|
||||
in "venv") and select one with fzf.
|
||||
|
||||
-c, --cdvenv Change to the venv directory instead of going back to the
|
||||
current working directory
|
||||
-t, --tmsu list only venvs in a directory with tmsu tag lang=python
|
||||
HELP
|
||||
exit
|
||||
fi
|
||||
|
||||
ORIGDIR=$PWD
|
||||
|
||||
venvsh() {
|
||||
cd $1
|
||||
. bin/activate
|
||||
if [[ -z $cdvenv ]]; then
|
||||
cd $ORIGDIR
|
||||
fi
|
||||
$SHELL
|
||||
}
|
||||
|
||||
if [[ -n $tmsu ]]; then
|
||||
venv=$(
|
||||
for i in $(tmsu files --directory lang=python); do
|
||||
[[ -d $i/venv ]] && echo $i/venv
|
||||
done | fzf)
|
||||
if [[ -n $venv ]]; then
|
||||
exec venvsh $venv
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n $newvenv ]]; then
|
||||
python -mvenv ${1:-venv}
|
||||
exec venvsh ${1:-venv}
|
||||
fi
|
||||
|
||||
if [[ -n $1 && -e $1/bin/activate ]]; then
|
||||
exec venvsh $1
|
||||
fi
|
||||
|
||||
venv=$(fd -I -t d 'venv$' $1 | fzf)
|
||||
if [[ -n $venv ]]; then
|
||||
exec venvsh $venv
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue