Friday, December 6, 2019

windows - How can I get ConEmu, Far Manager and the VS Developer Command Prompt to play nice together?




I'm currently trying to set up my environment such that I can open a ConEmu tab and it will automatically initialize Far Manager and the VS Developer Command Prompt environment.



My failed attempt was this:



cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86 & far -new_console:d:C:\My\Code


This works in that it accomplishes what I want, but ConEmu doesn't like it because it leaves an active cmd.exe instance, so when you try to close the tab you will always get a warning, which is not ideal.



If you've never seen this before, this is what pops up on tab closure if you use the above task:




http://i.imgur.com/o0GyS5I.png



After a whole bunch of searching I found this link which contains a comment at the bottom by the ConEmu author:



http://www.gurustop.net/blog/2014/02/01/using-visual-studio-developer-command-prompt-with-powershell/



He says this:





Yep, that is working. But this method left cmd.exe in your working process tree.



Another way - run vcvarsall.bat from you shell (PowerShell or Far Manager) and export changed environment from cmd to the parent process. The advantage - you can set up different settings at run time.



Description: https://code.google.com/p/cone...



And example command (I'm using that from Far Manager):
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 & "%ConEmuBaseDir%\ConEmuC.exe" /export=CON





The problem with this however is that I have to run this command manually after running far. I can't seem to find a way to automatically run that command after initializing Far.



It's not really a viable solution to do it manually because I have so many different environments to set up. Consider that I want a different tab for each compiler I'm using (MSVC, Clang, GCC, Intel C++ - sometimes multiple version of each, and pretty much always multiple architectures).



Basically I need a way to set up a task such that I can either run a batch file, followed by Far (so it inherits the env vars) without leaving a dangling cmd.exe instance. Or, I need to be able to set up a task such that I can automatically run a command (different per task) after running Far.



I'm pretty sure there would be some black magic way to do it, but I'm not familiar enough with ConEmu/Far yet to figure it out.



If I get super desperate I'll probably end up writing a plugin, but I'd rather avoid that if I can.


Answer





  1. ConEmu has forking abitily. So, you may just call



    -new_console:d:C:\My\Code cmd.exe /c ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86 & ConEmuC -fork -c far"

  2. Far Manager has its own Macro system. You may either set up "Auto started" macro, or just pass it via command line. Consider proper quotation! Just change F2 F1 to your keys sequence. Easies way is adding required command to the F2 (User Menu).



    -new_console:d:C:\My\Code cmd.exe /c ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86 & far "lua:Keys(\"F2 F1\")""



No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...