Skip to content

Instantly share code, notes, and snippets.

@danielk333
Last active April 7, 2022 05:41
Show Gist options
  • Save danielk333/635fa22f43beffe614355a4902046212 to your computer and use it in GitHub Desktop.
Save danielk333/635fa22f43beffe614355a4902046212 to your computer and use it in GitHub Desktop.
venv_tools_fish
function activate
source ~/venvs/$argv/bin/activate.fish
end
function lazyvenv
set -l name (basename (pwd))
if test -d ~/venvs/$name
activate $name
else
echo "No venv found: creating venv"
venv
if test -d ~/venvs/$name
activate $name
end
end
end
function venv
if test (count $argv) -eq 0
set venv_target (basename (pwd))
else
set venv_target $argv
end
echo "New venv target=$venv_target"
if not test -d ~/venvs
mkdir ~/venvs
end
if test -d ~/venvs/$venv_target
echo "Folder '~/venvs/$venv_target' exists, choose a different name for new venv"
else
python -m venv --upgrade-deps --system-site-packages ~/venvs/$venv_target
echo "Created virtualenv $venv_target"
end
end
function venvs
for dr in ~/venvs/*
echo (string split / $dr)[-1] "| python" (cat $dr/pyvenv.cfg | grep version)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment