6

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 
2
  • So what's your question? – Danack May 9 '13 at 17:29
  • @Danack - Seriously? Others seemed to understand it.. – Neil May 10 '13 at 8:36
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.

2
  • 1
    Perfect, creates exactly what I wanted. – Neil May 10 '13 at 8:35
  • 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 Jul 26 '18 at 0:07
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.

5
  • Can you give me an example of how to open new tabs using my .bat example? – Neil May 9 '13 at 15:21
  • @Neil added one. – Justin Dearing May 9 '13 at 15:41
  • 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 – Neil May 9 '13 at 16:30
  • @Neil I've nows showed you three ways to do it. – Justin Dearing May 9 '13 at 17:58
  • I have upvoted you, but accepted Maximus' answer as it is perfect for what i needed, thanks for your help. – Neil May 10 '13 at 8:36
1

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.
-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

1
  • 1
    There 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' May 8 '19 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.