porterjamesj/virtualenvwrapper.el

Double Prompt

Closed this issue · 3 comments

This is great little tool that just works. My issue is largely cosmetic. When I create a new shell, I get a double prompt that looks like this.

[user@host ~]$ (environ)[user@host ~]$

Any idea why?

This is great little tool that just works.

Thanks! "just works" was definitely my goal so that's good to hear.

Any idea why?

Yeah, this has to do with the hacky way the shell support works. You would think that nothing would need to be done to get the shell to work smoothly, since all the appropriate environment variables are set in Emacs, and therefore would be set in a subprocess (such as the shell). The problem with this is that virtualenv and virtualenvwrapper are more than just a pile of environment variables, they're also a bunch of shell functions (deactivate, workon, etc.) that need to get sourced into the newly running shell. "No problem", you might think, "we'll just make the shell source the virtualenvwrapper.sh script when it starts up". Unfortunately, it isn't that simple, since virtualenvwrapper.sh crashes and burns if it finds it's environment variables are already set. So what we actually have to do is unset all the relevant environment variables, launch the new shell, then source virtualenvwrapper.sh, then workon / activate the correct environment (thus restoring the variables we unset so that we could get virtualenvwrapper.sh loaded).

The second prompt you see getting printed out there is the result of injecting the command to activate the environment into the new shell immediately after it starts up (code is here). Ideally the first prompt (the one from when the shell initially starts up) would be suppressed. I remember looking for a way to do this back when I first wrote this code and not finding anything. If you're aware of a way that would be awesome, but if not I'm happy to tradeoff a bit of a visual WTF for that "just works" feel once you actually try to use the shell. :)

also let me know if that explanation doesn't make sense, figuring all that out was definitely a WTF computers moment.

@creese doing some cleanup and I'm going to close this. While I agree it's an annoyance, I don't think it's possible to fix it, as I explained above. Let me know if you have any more questions or ideas!