GithubHelp home page GithubHelp logo

sentriz / fish-pipenv Goto Github PK

View Code? Open in Web Editor NEW
200.0 18.0 28.0 43 KB

๐ŸŸ๐Ÿ a fish plugin that automatically activates the pipenv subshell

Home Page: http://pipenv.org

License: MIT License

Shell 100.00%
pipenv python virtualenv fish-shell fisher

fish-pipenv's Introduction

hooks into a change in PWD to automatically launch a Pipenv shell for your Pipenv project

note: this project was previously maintained by @kennethreitz

Installation

With Fisher

fisher install sentriz/fish-pipenv

With Fundle

Add:

fundle plugin "sentriz/fish-pipenv"

to your config.fish (create one if it doesn't exist), reload your shell and run:

fundle install
omf install https://github.com/sentriz/fish-pipenv

Configuration options

Suitable for your ~/.config/fish/config.fish

# set if your term supports `pipenv shell --fancy`
set pipenv_fish_fancy yes

Potential Issues

Mac OS

After installing pipenv, running the $ pipenv command may yield the following error:
Install http://docs.pipenv.org/en/latest/ to use this package.

Reason for the error

The problem is that, the pipenv package rightly could not find the pipenv command. The situation with fish shell is that it executes scripts in the /Users/user/.config/fish/config.d folder before executing config.fish and the pipenv package creates a link in the config.d folder hence it is executed before config.fish.

Now depending on how you installed pipenv or how soon your $PATH is loaded you could be faced with the above error.

Solutions

  1. You could install pipenv with the command $ pip3 install pipenv. Pipenv will then be installed in /usr/local/bin. On some systems the folder /usr/local/bin is added to $PATH by the system which means that it will be available before fish goes fishing for scripts in /Users/user/.config/fish/config.d

  2. Or you could create a file say 000-env.fish (or whatever you want to call it), and place it in /Users/user/.config/fish/config.d. In this file set the path to the folder where pipenv was installed. E.g if pipenv was installed via pipsi, then the command will be something like set -x PATH /Users/user/.local/bin $PATH

    If pipenv was installed via $ pip install pipenv, then note that pip (python2) now puts its executables in /usr/local/opt/python/libexec/bin.

    The 000 preface is to ensure that, that script will be executed first before the others in config.d. You don't have to prefix the file with 000 it is abitrary. Just give it a name that places it at the top of the pile.

  3. Or assuming you also have fish-pyenv you can add a universal variable to your fish_user_paths following mhugbin:

    set -U fish_user_paths ~/.pyenv/shims $fish_user_paths

See #1

License

MIT

fish-pipenv's People

Contributors

chapmanjacobd avatar colde avatar domoritz avatar jorgebucaran avatar kennethreitz avatar ovidner avatar parths007 avatar peterschutt avatar psliwka avatar sentriz avatar shuuji3 avatar spool avatar techalchemy avatar timofurrer avatar tyilo avatar wy-z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fish-pipenv's Issues

An error in the documentation?

$ fisher add sentriz/fish-pipenv
Installing 2 plugin/s
! Fetch add github.com/fisherman/add
OK Copy pipenv
! There was an error installing add or more plugin/s.
Try using a namespace before the plugin name: owner/add

This went wrong. What do I do?

"exit" exits parent shell, too

If I open a new terminal, then cd into a directory with a Pipfile, the virtualenv shell is launched, but in such a way that if I subsequently type exit, my whole terminal exits, rather than just the virtualenv shell.

Does this work with Oh my Fish?

I installed this plugin with OMF omf install https://github.com/sentriz/fish-pipenv but it doesn't load the virtual env when I cd into a repo with a Pipfile. Does it work for you?

poetry env info -p is slow

poetry env info -p >/dev/null 2>&1 is slow, therefore, cd command become slow!
Need to search alternatives

auto-deactivate, like pyenv-virtualenv

If I have pyenv-virtualenv hooks installed, then when I cd into a (sub)directory of a project, the virtualenv is automatically loaded. When I cd out of that project, the virtualenv is unloaded.

This plugin enables the activation behavior, but not yet the deactivation. Could the deactivation behavior be added?

pipenv doesn't allow .envrc files to be sourced

For my flask apps, I've recently started using direnv to load project specific environment settings via .envrc files. I use the fish shell and have as such installed the pipenv plugin for integration with pipenv. However, when I cd into a pipenv created virtualenv containing a .envrc, the fish pipenv plugin rightly activates the virtualenv environment but the .envrc file is not sourced.

Therefore if I give the command flask run for example, I get the warning

Usage: flask run [OPTIONS]
Error: Could not locate Flask application. You did not provide the FLASK_APP environment variable.

I therefore have to Ctrl+D to exit the virtualenv, which then causes direnv to source the .envrc, after which I give the pipenv shell command to activate the virtualenv again.

To save me from doing this every time, I've uninstalled the pipenv plugin for the moment.

pipenv shell with --Fancy option

Is there a way to automatically select the --fancy option for pipenv shell command? The reason is that it displays only one listing of the virtual environment name.

pipenv shell
(exams01-rcG8nKlv) ! ๎‚ฐ โ—ฐยณ exams01-rcG8nKlv ๎‚ฐ ~/d/exams01 ๎‚ฐ ๎‚  โ€ฆ ๎‚ฐ

pipenv shell --fancy
โ—ฐยณ exams01-rcG8nKlv ๎‚ฐ ~/d/exams01 ๎‚ฐ ๎‚  โ€ฆ ๎‚ฐ

pipenv command now prompts me to install latest to use plugin

I've just upgraded to the latest pipenv plugin for fish shell. Since the upgrade all pipenv commands prompt me with the following
Install http://docs.pipenv.org/en/latest/ to use this plugin.
I already have pipenv installed to the latest. The output of command -s pipenv is /Users/napo/.pyenv/shims/pipenv

As it stands, I can't use pipenv.

Pipenv called for any directory when i cd into it.

I just installed fisher and pipenv (used fish without a plugin manager before), and when i open a shell and cd to any directory, it auto creates a virtualenv/Pipfile and load the subshell. It's only once per new shell, but it's not really an expected or desirable behavior

gabriel@gryphon:~> mkdir plop
gabriel@gryphon:~> cd plop
Creating a Pipfile for this project...
Creating a virtualenv for this project...
โ ‹No virtualenv has been created for this project yet!
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/gabriel/.local/share/virtualenvs/plop-Fqtl0Bn_/bin/python2
Also creating executable in /home/gabriel/.local/share/virtualenvs/plop-Fqtl0Bn_/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

Virtualenv location: /home/gabriel/.local/share/virtualenvs/plop-Fqtl0Bn_
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.

Thanks for all the fish!

edit: i had virtualfish and auto_activation.fish, installed (without fisherman) i commented/moved them and i still get the behavior.

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.