In Part 1 of my Web Development Tools series I wrote about two tools I use nearly every day to help me get my work done. Whereas those tools serve very different purposes, today I want to discuss how to set up a tool chain.
I am a back-end (server side) web developer working in Windows writing C# and SQL code for ASP.NET web sites running on the Kentco CMS. But I’m also an AngularJS architect and front-end (browser/client side) developer writing javascript and using tools like node.js, npm and Git liberally.
I need my set of tools to be as flexible as the role I fill at work and as varied as the problems I have to solve each day. The way I approach this is to use multiple tools designed for a specific purpose instead of a complex, all-encompassing behemoth as a one-stop-shop. When a set of tools works well together, becoming an amalgam, it’s called a tool chain and I’m going to show, step by step, how to replicate my tool chain of ConEmu, Git for Windows, node.js and npm. We will look at ConEmu and Git for Windows today and I’ll discuss Node.js and npm in a later entry in this series.
Git for WIndows
Git for Windows is the Windows port of the Git version control system’s command line tools for Linux (Git and the open source Git management system Gitlab was covered in a previous post by our head of IT Operations, Ryan). Git for Windows comes with a Bash shell emulation referred to as Git Bash which allows a Windows user to run a subset of often used Linux commands and get a very similar command line experience to what Mac and Linux users know and enjoy. The Git GUIs that are available for Windows like Github Desktop, SourceTree and GitKraken are beautiful and feature rich applications but I feel they abstract away too many details and can become cumbersome for the simple and common commands that can be run at the command line. In addition, if you are already working at the command line with tools like npm and node.js, switching back and forth between your shell and a GUI will slow you down.
To begin, download and install Git for Windows. The default installation options will work fine - if you don’t know what an option is just leave it be. Below you can see screenshots of the options I selected.
Note: Git should install to C:\Program Files\Git
.
ConEmu
ConEmu is a terminal for Windows which can run shells of the user’s choice while providing features missing in the default Windows terminal + shell combo (also known as cmd.exe). There are other very nice replacements for cmd.exe like mintty, console2 and even Powershell, but I feel that ConEmu provides the options I need (multiple pre-defined shell configurations) and the options I want (multiple tabs, view splitting, colored text, custom hotkeys).
Note: cmd.exe was slightly improved in Windows 10 but it’s still not a very nice user experience if you are typing at the command line often.
Download and install ConEmu with the default options.
When you run ConEmu for the first time you will be asked to confirm some default settings. Something you will quickly notice is just how many settings there are for ConEmu, which I consider to be one of its strengths as these do not all require customization, only the ones you wish to modify.
Note: ConEmu will install to C:\Program Files\ConEmu
.
One section we will be customizing is the Tasks list. Press Win+Alt+T
or go to the options button in the top right of the screen -> Settings -> Startup -> Tasks to open up the Tasks list. Tasks are the different pre-defined shell configurations you can create. Having multiple configurations defined could allow you to open Git Bash in your home directory in one tab and then open a Powershell and an Administrator cmd.exe session at your drive root in two additional tabs just by clicking items in an easy to access menu.
Once you have the tasks list open there will be one Task in particular we wish to modify. Look for the Task named {Bash::Git bash}
and view its settings. Check the boxes for “Default task for new console” and “Default shell”. Set the Task Parameters to /icon %PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico /dir "C:\path\to\somewhere"
where C:\path\to\somewhere
is the directory in which you want your shell to start. And set the Commands %PROGRAMFILES%\Git\bin\sh.exe --login -i -new_console
Now select Startup from the left hand options list and set the Startup task from the Specified Named Task dropdown to {Bash:Git bash}. Go ahead and save your settings, close ConEmu and then run it again.
If you have Git for Windows installed and you copy-pasta’d like a pro you should now see a Bash shell in your ConEmu terminal emulator with commands like ls
and git config -l
available (Git Bash means it’s a Bash shell with Git added to your PATH
environment variable).
Git and Bash configuration
You are going to want to setup a couple of configuration files for your tools which I will link to below with short descriptions. These files are all typically located in your home directory on Windows (C:\users\youruser\
) which you can get to at the command line using the shortcut cd ~
-
.gitconfig
- This is the configuration for your Git environment and it contains various defaults and customizations related to you and your preferences when working with Git. -
.bashrc
- This is the configuration for your Bash environment which can contain many customizations for your shell, like what shortcuts (aliases) for commands you have available, custom shell scripts, UI tweaks and much more. -
.bash_profile
- Another shell configuration file where non-shell specific customizations can be kept. There are many resources available to explain the differences between.bashrc
,.bash_profile
,.profile
, ect… so I will defer to them. I keep myPS1
(shell prompt) definition, which customizes its look, feel and functionality, in my.bash_profile
Hopefully after all this installation and configuration you will end up with ConEmu looking a bit like this.
We will pause here for now and pick up next time with ssh configuration to connect Git and your Bash shell to sites like Github.com by allowing your shell commands to be authenticated. We will also cover node.js, npm and configuring your environment PATH
to make your shell even more powerful.
Fortunately there is a lot of documentation covering ConEmu and Git for Windows if you wish to continue reading or need help solving a problem and you can always feel free to drop us a comment if you have any questions.