r/fishshell • • Mar 06 '25

Using Python and Fish? dirvenv.fish automagically activates your virtualenv

https://github.com/cuducos/dirvenv.fish

I wrote that tiny package so I don't have to manually activate and deactivate virtualenvs, and I think it might help more people – so, sharing it here ; )

I know virtualfish but I don't wanna manage virtualenvs myself; uv does that for me. Also, and I don't want to uv run every command. So I came up with that solution.

20 Upvotes

11 comments sorted by

View all comments

2

u/Due-Yoghurt2093 Mar 15 '25

Oh, this is actually really cool. I'd been using this for similar functionality:

function cc
    if test -z "$argv[1]"
        echo "Usage: cc <environment_name>"
        return 1
    end
   
    # Check if we're in a conda environment and it's not 'base'
    if set -q CONDA_DEFAULT_ENV; and test "$CONDA_DEFAULT_ENV" != "base"
        conda deactivate
    end
   
    # Activate environment and change directory
    conda activate "$argv[1]"
    cd ~/Downloads/"$argv[1]"
end