7

I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:

  • Open a Git Bash, name the console "X", set the current directory to "Y".
  • Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"
  • Open a regular command window, run the command "cd D/E/F", "grunt watch"

I want the second and third consoles to appear alongside each other, but underneath the first console. So far I am stuck getting commands to run; I have a task that runs the following:

"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:n:t:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:s1TVn:t:Vagrant"
cmd "-cur_console:s2THn:t:Third"

Reading the ConEmu wiki led me to the new_console and cur_console switches, but I'm having trouble figuring out if I can somehow enter commands in the Task setup, or maybe if I can have it run a .bat script on each console.

OleVik
  • 1,222
  • 3
  • 14
  • 28

1 Answers1

12

No colon is needed between switches (n & t for example).

cmd has /k switch to run commands.

I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with &. I'm not sure about second line, you need to check it yourself.

"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:nt:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
cmd -cur_console:s1TVnt:Vagrant /c vagrant up & "%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i"
cmd -cur_console:s2THnt:Third /k cd /d "D\E\F" & grunt watch
Maximus
  • 10,751
  • 8
  • 47
  • 65
  • Implicitly you highlighted the issue I was having: Getting Bash to behave as I expect cmd to. A quick rewrite using your examples made it possible to run everything I needed using just shell, but keeping the git bash for a few tasks that had to be done manually anyway. Thanks! – OleVik Feb 16 '14 at 10:30
  • 6
    Can you please post your updated ConEmu task for the benefit of others trying to accomplish something similar to what you did? – otravers Mar 08 '14 at 16:18
  • 3
    There's a `-c` command for `bash.exe` that will run a command but unfortunately keep the terminal in interactive mode after. There's also [this solution](https://serverfault.com/a/586272/207363) by using an `--init-file` but I could not get this to work. @OleVik if you're still alive, can you come back and comment :3? – Cobertos Sep 16 '18 at 19:48
  • 1
    Several ways are possible: https://conemu.github.io/en/CygwinStartCmd.html – Maximus Sep 16 '18 at 23:32