I've switched back to Windows on work recently. Turned out I am too attached to Far Manager(these days Far is even greater with ConEmu). If you are a developer on Windows and you do not know about this stuff, go check it out. It is fantastic. Scott Hanselman has a nice post about it.
I am also more into python development these days. Which (for me) means usage of conda and it's environments. Anaconda developers suggest that on Windows one should start a special Anaconda Propmt. I would like to be able to activate environments straight from Far. Sounds easy: just be sure to be able to run conda. However once I do
conda activate new-env cona env list
I observe that environment has not been changed. Environment activation is basically a modification of environment variables.
Here is how it looks like:
The reason for such behaviour is that Far spans a new CMD process for every command. So in our case
conda activate new-env will be a new process, which will modify environment variable, but these changes will die once process is ended.
FarCall plugin for the rescue. This plugin allows one to call a batch file and imports environment variables to Far process. Neat. Once you have the plugin in place, you can activate the environment like this:
call:conda activate new-env
Note that this won't change the command propmpt. But we can fix this too. I did it through Far Manager settings for the command propmpt (
Options -> Command line settings -> Set command line prompt format). Set the value to (see UPDATE 2 about it):
And the last bit to it, you actually have to go and create a user-scoped environment variable
CONDA_PROMPT_MODIFIER and make it non-empty. I assigned it a single space. I observed that empty
CONDA_PROMPT_MODIFIER will result in command propmpt that will print the name of the environment variable instead of printing nothing.
Here is the result:
This won't work with deactivation. During deactivation conda's script does things like this:
@SET CONDA_PREFIX= @SET CONDA_DEFAULT_ENV= @SET CONDA_PROMPT_MODIFIER=
which besically removes environment variables. When it is time for FarCall to enumerate environment variables, there are no
CONDA_PROMPT_MODIFIER, so FarCall does not propagate the empty value (or reset). Sigh!
Somehow I overlooked that one can use
PROMPT environment variable instead of
CONDA_PROMPT_MODIFIER. It is better because then Far will work nicely not only with conda, but with Pipenv (in case you use it). So define an environment variable
PROMPT and set command line format in Far to
%PROMPT%. My default value for