After many years of playing with alternative consoles for Windows, I had settled on Console 2 for most of my Node.js and general Windows tasks, and the Cygwin port of Bash for my Git, SSH, and VM-related tasks. Recently though I was introduced to ConEmu, and it has quickly become my favorite.

ConEmu will run any shell that you have installed, and adds features that make using those shells more efficient and fun to use than if you were to run them independently.

If you’re using Node.js as part of your Web development workflow, chances are that you’re taking advantage of a task runner like Grunt or Gulp to automate certain tasks, e.g. concatenation, minification, and linting. I’m going to share how to create a task in ConEmu that will automatically split your view in half, create a new console on the right side, and then run grunt watch in that new console from your current directory.

Running Grunt Watch in a Split ConEmu Tab

ConEmu Task Settings for Grunt Watch

Setting up this task is incredibly simple:

Grunt Watch Task Settings in ConEmu

  1. Hit Win + Alt + P to bring up the ConEmu Settings window
  2. Select Tasks under the Startup menu
  3. Create a new task by clicking the + button
  4. Give this new task a name, like Scripts::Grunt Watch
  5. For Task parameters, enter /dir %cd% so that the new console is started in the same directory as your current console
  6. In the Commands box, enter cmd.exe /k "%ConEmuBaseDir%\CmdInit.cmd" -cur_console:sH & grunt watch
  7. Hit Save settings

It is as simple as that. If you are having any trouble, click on the screenshot of the settings above to view it at full size and verify what you entered.

Now you can simply open ConEmu, cd to the root directory of your project, and run this new task. What you’ll have is your primary console for running commands manually on the left, and a console running grunt watch on the right, allowing you to keep an eye on all of your automated tasks while you continue to work.

POSTED BY
POSTED IN Tutorials
DISCUSSION 2 Comments

2 Responses to : Automatic Grunt Watch in ConEmu Split Tab

  1. Maximus5 says:

    Minor fix. Double quote before -cur_console is erroneous. So it would be

    cmd.exe /k “%ConEmuBaseDir%\CmdInit.cmd” -cur_console:sH & grunt watch

    One more note. “%cd%” is working from-the-box in cmd.exe only. If anyone has problems with starting new task in current directory, just read docs: https://conemu.github.io/en/ShellWorkDir.html

  2. Kurt Maine says:

    Thanks a lot, Max, I fixed the typo in the post, screenshot, and my own code.

    I really appreciate all of your work on ConEmu, it’s great.