Automatic Grunt Watch in ConEmu Split Tab
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 makes using those shells much 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.
ConEmu Task Settings for Grunt Watch
Setting up this task is incredibly simple:
- Hit Win + Alt + P to bring up the ConEmu Settings window
- Select Tasks under the Startup menu
- Create a new task by clicking the + button
- Give this new task a name, like
Scripts::Grunt Watch
- For Task parameters, enter
/dir %cd%
so that the new console is started in the same directory as your current console - In the Commands box, enter
cmd.exe /k "%ConEmuBaseDir%\CmdInit.cmd" -cur_console:sH & grunt watch
- 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.