justinmayer / virtualfish

Fish shell tool for managing Python virtual environments
MIT License
1.06k stars 100 forks source link

Semi-automatic activation #204

Open Evpok opened 3 years ago

Evpok commented 3 years ago

Feature Request

I really like the idea of linking directories to envs, but at the same time I don't always want to activate the linked env when I cd into a dir. It would be nice if there was way to manually activate the environment linked to by vf connect even with auto_activation disabled. This could take the form of a dedicated command, or just the behaviour of vf activate without specifying an env (look into VIRTUALFISH_ACTIVATION_FILE and activate the env you find there`.

justinmayer commented 3 years ago

Hi @Evpok. Environments shouldn't be automatically activated via cd if automatic activation is disabled. I don't have time to parse and understand what you mean, so it's important when filing issues to be really specific and unequivocally clear. With that in mind, can you elaborate?

Evpok commented 3 years ago

Hi @justinmayer, let me try to reformulate: I wish to have links between directories and environments without using automatic activation, which is currently not supported. The behaviour I am looking for is for vf activate to look for a .venv (or whatever vf connect creates) file in the current directory, and if there is one, to activate the corresponding environment.

justinmayer commented 3 years ago

So, to summarize, you want to save a few keystrokes by typing vf activate instead of vf activate (cat .venv). Do I have that right?

Evpok commented 3 years ago

More like vf activate (cat $VIRTUALFISH_ACTIVATION_FILE) but yes, that's the idea.

justinmayer commented 3 years ago

My suggestion would be to define an abbreviation, replacing vfa with your desired short-cut/macro:

abbr -a vfa vf activate (cat $VIRTUALFISH_ACTIVATION_FILE)

That way you get what you want in three keystrokes.

But if you want to submit a pull request that activates the relevant virtual environment when vf activate is invoked with no arguments and a $VIRTUALFISH_ACTIVATION_FILE is present in the current working directory, I can't think of any obvious impediments to merging it.

Thoughts?

Evpok commented 3 years ago

Right, I'll do both: start with the abbreviation and see if I can get a PR to work. Thanks!