Run series of commands in different tabs in conemu

5

4

I have a .bat file which used to open 3 cmd windows each a different colour. I am now using conemu and would like to now do the same but in different tabs. How do I do that?

My .bat file:

cd /D x:\mercurial\blah\blah
start cmd /k color 4C
cd /D x:\mercurial\blah\blah\solr
start cmd /k color 5D 
cd /D x:\mercurial\blah\blah\rep
start cmd /k color 2A 

Neil

Posted 2013-05-09T12:37:18.943

Reputation: 152

So what's your question? – Danack – 2013-05-09T17:29:06.303

@Danack - Seriously? Others seemed to understand it.. – Neil – 2013-05-10T08:36:55.427

Answers

7

Run this from your batch file (one-line command)

start "Three tabs" "C:\Program Files\ConEmu\ConEmu.exe" /cmdlist ^> cmd /k color 4C -cur_console:d:x:\mercurial\blah\blah ^|^|^| cmd /k color 5D -cur_console:d:x:\mercurial\blah\blah\solr ^|^|^| cmd /k color 2A -cur_console:d:x:\mercurial\blah\blah\rep

This starts new ConEmu window with three tabs, first tab will be active. start "Three tabs" ... is just an example usage of start command.

Maximus

Posted 2013-05-09T12:37:18.943

Reputation: 19 395

Works perfect. Worth noting that if you'd like to run a command once in the directory you need to add it after each /k flag. Cheers! – kplates – 2018-07-26T00:07:47.580

1Perfect, creates exactly what I wanted. – Neil – 2013-05-10T08:35:34.937

4

To do this from a batch file, try the /cmd switch. See the conemu cmdline reference for more info.

e.g.:

"C:\Program Files\Far Manager\ConEmu64.exe" /single /cmd "cmd /k cd c:\symbols" 

To do this from the New Console Dialog see below: New Console Dialog

To launch a new tab from an existing conemu tab, see the -new_console switch.

Justin Dearing

Posted 2013-05-09T12:37:18.943

Reputation: 2 704

Can you give me an example of how to open new tabs using my .bat example? – None – 2013-05-09T15:21:53.517

@Neil added one. – Justin Dearing – 2013-05-09T15:41:12.807

Sorry I'm useless with cmd stuff, I've tried adding this to "new console dialog" with path to my conemu exe and path but it fails – None – 2013-05-09T16:30:50.113

@Neil I've nows showed you three ways to do it. – Justin Dearing – 2013-05-09T17:58:51.587

I have upvoted you, but accepted Maximus' answer as it is perfect for what i needed, thanks for your help. – Neil – 2013-05-10T08:36:04.110

0

I've had terrible try making it work. Perhaps it is because I am using Cmder or one of my settings. Eventually I wrote the following script that does exactly that - Opens 3 tabs, both in single window using vertical split:

ConEmu.exe /single /cmd cmd /k "%ConEmuDir%\..\init.bat & cd www & npm start" -cur_console:s50V:n:t:"web" ConEmu.exe /single /cmd cmd /k "%ConEmuDir%\..\init.bat & cd server & api.py" -cur_console:s50V:n:t:"backend" ConEmu.exe /single /cmd cmd /k "%ConEmuDir%\..\init.bat & cd c:\nginx\ & nginx" -cur_console:s50V:n:t:"nginx" ConEmu.exe /single /cmd cmd /k "%ConEmuDir%\..\init.bat" -new_console:t:"cmd" sleep 1 exit

Some notes:

  • The script must be run from within a ConEmu tab
  • %ConEmuDir%\..\init.bat needed to initialize Cmder's pretty shell
  • Optional: sleep 1 & exit closes the tab that initiated the script.

VitalyB

Posted 2013-05-09T12:37:18.943

Reputation: 225

-1

This solution uses Cmder which is a packaged version of ConEmu with additional enhancements.

The following command opens three different tabs split into 3 panes, with different colored tabs and different working directories set.

start "Three Tabs" ConEmu /cmdlist ^> cmd /k "%ConEmuDir%\..\init.bat & color 4C & cd C:\Temp" -cur_console:n:t:"Tab 1" ^|^|^| cmd /k "%ConEmuDir%\..\init.bat & color 5D & cd c:\" -cur_console:s1T60Hn:t:"Tab2" ^|^|^| cmd /k "%ConEmuDir%\..\init.bat & cd C:\Projects" -cur_console:s2T50Vn:t:"Tab 3"
  • The script must be run from Cmder, it will open a ConEmu session
  • %ConEmuDir%\..\init.bat initializes the Cmder shell
  • color 4C will set the background and foreground colors
  • cd C:\Temp sets the working directory per tab
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground.  Each digit
can be any of the following values:

    0 = Black       8 = Gray
    1 = Blue        9 = Light Blue
    2 = Green       A = Light Green
    3 = Aqua        B = Light Aqua
    4 = Red         C = Light Red
    5 = Purple      D = Light Purple
    6 = Yellow      E = Light Yellow
    7 = White       F = Bright White

Split tabs screenshot

Steve B

Posted 2013-05-09T12:37:18.943

Reputation: 1

1There might be an answer here, but it’s hard to tell through all the smoke. What is init.bat?  Where does this set the working directories (that the question asks for)?  Where does this set the colors (that the question asks for)?  Can you explain what this does and how it works? … … … … … … … … … … … Please do not respond in comments; [edit] your answer to make it clearer and more complete. – G-Man Says 'Reinstate Monica' – 2019-05-08T22:12:15.393