8000 GitHub - kjozsa/dirvenv.fish: 🐍 Automagically activated and deactivates virtualenv in Fish
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kjozsa/dirvenv.fish

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dirvenv

Fish shell tooling to automagically activate and deactivate Python's virtualenv when moving between directories.

⚠️ This is a Fish shell script, it will not work on Bash or Zsh.

For example, let's say you have a project in ~/my-project with a virtualenv inside:

~ $  # note that no virtualenv is active
~ $ cd ~/my-project
(.venv) my-project $  # note that the virtualenv was activated
(.venv) my-project $ cd ~
~ $  # now the virtualenv is deactivated

Features

It looks for venv and .venv, but it is customizable

By default it will look for .venv or venv. But you can replace that with DIRVENV_DIRS environment variable. For example, if you want it to look for virtualenv called forty or two:

set -x DIRVENV_DIRS forty,two

It only deactivates a virtualenv that was activated automatically

If you manually activates a virtualenv, dirvenv will not deactivate it.

It detects virtualenv above the current directory in the tree

For example, if you have ~/my-project/.venv and you cd ~/my-project/tests, it will activate the virtualenv in the parent directory (recursively).

It is session-aware

If you have more than one shell, dirvenv from one shell will not mess up with the magic in the other shells.

You can ignore directories

If you want dirvenv to ignore any directory, just use DIRVENV_IGNORE with full paths to the directories. For example:

set -x DIRVENV_IGNORE /not/my/monkeys,/not/my/circus

From now on, dirvenv will ignore any action in both these directories and their sub-directories.

Install

Probably it works with Fisher, but I haven't tested it myself:

$ fisher install cuducos/dirvenv.fish

Alternatively you can use the install.fish script:

$ curl https://raw.githubusercontent.com/cuducos/dirvenv.fish/refs/heads/main/install.fish | source

Uninstall

There is an uninstall.fish script for that:

$ curl -LO https://raw.githubusercontent.com/cuducos/dirvenv.fish/refs/heads/main/uninstall.fish
$ source uninstall.fish
$ rm uninstall.fish

Acknowledgements

Thank you, direnv! The similarity in the name is intentional, the user experience of direnv is so great I wanted to offer the same seamless smooth experience with dirvenv : )

About

🐍 Automagically activated and deactivates virtualenv in Fish

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%
0