Coder Social home page Coder Social logo

aohorodnyk / fish-autovenv Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 16 KB

Automatically activate/deactivate Python virtual enviroments when entering/leaving a directory

License: MIT License

Shell 100.00%
fish fish-shell fish-plugin python venv venv-python virtualenv virtualenv-manager

fish-autovenv's Introduction

AutoVenv

Fisher plugin to automatically activate/deactivate Python virtual enviroments upon entering/leaving a directory.

MIT License

Why forked?

This project was forked from autovenv by timothybrown, which has not been updated for more than three years.

The project was forked because I wanted to add a few features and improve the plugin:

  • The plugin did not work with the new version of fish, and I wanted to keep it as simple as possible.
  • The plugin looked for virtual environments in the current directory, but not in the specified sub-directory. For example I store virtual env in a sub-directory called .venv.
  • Apply virtual environment when run a terminal in a directory with a custom virtual environment.
  • Search for virtual environments in the parent directories from bottom to top, instead of top to bottom it was implemented in the original plugin.

Install

Installation with Fisher:

fisher install aohorodnyk/fish-autovenv

About

Do you like the way Pyenv automatically switches between enviroments when you change directories and wish you could do the same thing with standard Python 3 venvs? Well, now you can! No complicated scripts, binaries or overhead needed; AutoVenv is a single file, pure fish solution.

Usage

Upon entering a directory that contains a Python venv (or any directory above it) AutoVenv will automatically activate it for you. Likewise, when moving below the venv's parent directory AutoVenv will deactivate it! AutoVenv can also handle cases where you move directly from one venv directory to another.

Settings

set -U autovenv_enable yes|no

Enables/disables autovenv functionality.

set -U autovenv_announce yes|no

Controls whether or not a message is printed when entering/leaving/changing venvs.

set -U autovenv_dir .venv

Set a directory or path to a directory that contains Python virtual environments. If empty, the current directory is used.

License

MIT © Timothy Brown

MIT © Anton Ohorodnyk

fish-autovenv's People

Contributors

aohorodnyk avatar timothybrown avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

osmollo be-ez

fish-autovenv's Issues

Error with starting in fish+tmux

Hi! Thx for doing this plugin, it is very helpful for me. Issue, that i reporting is not happening all the time.

Problem

After i start fish with tmux, it gives me error:

fish: Unknown command: deactivate
~/.config/fish/conf.d/autoenv.fish (line 52):
      deactivate
      ^~~~~~~~~^
in function 'applyAutoenv'
        called on line 71 of file ~/.config/fish/conf.d/autoenv.fish
from sourcing file ~/.config/fish/conf.d/autoenv.fish
        called on line 248 of file /usr/share/fish/config.fish
from sourcing file /usr/share/fish/config.fish

        called during startup
Deactivated Virtual Enviroment ()
sessions should be nested with care, unset $TMUX to force
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

After this error all funcationality of autovenv is not avaiable. Auto activation enviropment after entering directory is not happening.

After i remove tmux from fish-config traceback dissapears:

2024-04-26.09-14-06.mp4

How to reproduce

  • add tmux in fish.config
  • open fish (in my case, with alacritty)

but, again: this bug is not stable. Sometime it come up after update, than, in few days, it dissapears. Idk, why)

Do u have some thoughts in mind, how to solve this?

UPD: Error dissapeared again. What should i check, when it will appear again?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.