Skip to content

fish shell _pyenv_virtualenv_hook slow #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ephes opened this issue Jan 11, 2020 · 2 comments
Open

fish shell _pyenv_virtualenv_hook slow #338

ephes opened this issue Jan 11, 2020 · 2 comments

Comments

@ephes
Copy link

ephes commented Jan 11, 2020

Hi *,

thanks for this awesome project at first :).

I noticed that my fish shell got really slow when just pressing enter compared to bash and I figured out that the line "status --is-interactive; and source (pyenv virtualenv-init -|psub)" in my fish config caused this to happen. It looks like this line creates a function that listens to the fish_prompt event:

function _pyenv_virtualenv_hook --on-event fish_prompt
	set -l ret $status
  if [ -n "$VIRTUAL_ENV" ]
    pyenv activate --quiet; or pyenv deactivate --quiet; or true
  else
    pyenv activate --quiet; or true
  end
  return $ret
end

I'm not sure what this function does, but it seems to get executed every time the fish_prompt is shown, which causes indeed performance problems. Would it maybe be enough to just listen to "--on-variable PWD" which would cause it to be executed every time the working directory changes?

best,
jochen

@wolph
Copy link

wolph commented Feb 20, 2021

Not just on fish, it's very slow with zsh as well.

It takes 100ms for every line you type in your shell...

@ian-h-chamberlain
Copy link

ian-h-chamberlain commented Dec 27, 2022

Based on #45 and this issue, I modified my config.fish by adding "manual initialization" instead of calling virtualenv-init by default, like so:

pyenv virtualenv-init - fish >> ~/.config/fish/config.fish

Then replacing --on-event fish_prompt with --on-variable PWD --on-variable PYENV_VERSION.

This greatly improves my feedback loop between prompts for most cases, and at least I only have to pay the pyenv-virtualenv penalty when explicitly setting PYENV_VERSION or changing directories. Would it make sense to upstream these changes (perhaps along with a fish_postexec hook that looks for the pyenv shell etc. commands like mentioned in #45 (comment)) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants