Files
dotfiles/fish/functions/vv.fish
Tim McCarthy 0ac8fe6b72 Fish: vv for Python venvs
vv searches for and activates the nearest directory named "venv" in the
current directory upward (stopping if it finds a .git).
2020-12-07 11:15:21 -08:00

30 lines
498 B
Fish

#!/usr/bin/env fish
function vv
pushd . &> /dev/null
function find_root
set -l dir $PWD
if test -d $dir/venv
echo $dir
return 0
end
if test -d .git -o "$dir" = "/"
return 1
end
cd ..
find_root
end
if not find_root &> /dev/null
echo "Couldn't find venv"
popd &> /dev/null
return 1
end
source (find_root)/venv/bin/activate.fish
popd &> /dev/null
end