0

I'd like to create shortcuts to open shell consoles with project specific environment variables for each shell. I do this now with batch files like the below. They work but I need to open a CMD session and then run setenv_AA and setenv_BB every time. I'd like to just have shortcuts I can double click on and be running and ready to go. How can I do that?

Project 1 setenv_AA.bat

pushd D:\Projects\AA
set PYTHONHOME=C:\Python27x64\
set PROMPT=[2.7_x64] $p$_$g
set path=%PYTHONHOME%;%cd%\bin;%path%

Project 2 setenv_BB.bat

pushd X:\Work\BB
set PYTHONHOME=C:\Python34\
set PROMPT=[3.4] $p$_$g
set path=%PYTHONHOME%;%cd%\bin;%path%

What I've tried already:

A shortcut to the .bat file just runs ConEmu and than says "Press Enter or Esc to close console...". "C:\Program Files\ConEmu\ConEmu64.exe" /cmd D:\project_aa\setenv.bat does the same.

A shortcut like "C:\Program Files\ConEmu\ConEmu64.exe" /cmd set path=NEW;%path%; yields "ConEmuC: Root process was alive less than 10 sec, ExitCode=0. Press Enter or Esc to close console..."

Using /k /cmd yields a popup message of "unrecognized switch" while /cmd /k reveals it's calling CMD with /c (terminate after run):

'/k' is not recognized as an internal or external command,
operable program or batch file.

Current directory:
D:\p\ytdemv3.2016-03-08

Command to be executed:
"C:\Windows\system32\cmd.exe" /C /k set path=NEW;...blah...blah

ConEmuC: Root process was alive less than 10 sec, ExitCode=1.
Press Enter or Esc to close console...

How to change /C to /K?

matt wilkie
  • 17,268
  • 24
  • 80
  • 115
  • Ideal would be that whenever ConEmu starts it looks for `.conemurc` (or whatever) in the current folder and runs the contents. This would enable per-folder custom shells from Explorer right-click context "ConEmu here..." and bypass the need to create shortcuts. – matt wilkie Mar 09 '16 at 19:52
  • Related: http://stackoverflow.com/questions/13372299/run-autostart-console-bat-on-startup-or-new-tab-in-conemu (but instead of location specific settings it refers to global settings for every new session, more like an autoexec.bat from days of old). – matt wilkie Mar 10 '16 at 00:40

1 Answers1

1

Obviously, ConEmu is not a cmd.exe, so your /c or /k have no sense at all.

Use ...\ConEmu.exe /cmd cmd.exe /k your-batch.bat.

As for per-folder ".conemurc", that is rather bad idea. These conmands have to be executed per tab, but not globally. Also, these commands must be shell-specific and must be executed by the shell started in that tab. So, this idea doesn't differ from batch started with /k switch.

Maximus
  • 10,751
  • 8
  • 47
  • 65
  • Thanks! It was not understanding that I needed to both `/cmd` and `cmd.exe` that tripped me up. I though that `/cmd` was shorthand for calling cmd.exe. The .rc file was just me wondering of ways to avoid creating both a batch file and a shortcut for each project folder. You're the one to know if it's a bad idea though so away with it. ;-) – matt wilkie Mar 09 '16 at 22:31