A better command line for Windows
At Outlandish we mostly use Windows laptops but our servers run Ubuntu or FreeBSD. This reflects the general picture that around 90% of laptops and desktops run Windows while 70% of servers run some kind of Unix/Linux.
If you do web development there’s a good chance that you too spend part of your time on a Windows laptop typing commands to a remote server running Linux. In this post I’ll explain how to make switching between the two a bit less painful.
What you get
At the end, we’ll have a Bash shell running on Windows in a Console2 terminal with:
- resizable windows
- colour text
- click-and-drag copy and paste
- common UNIX commands like mv, rm, ls, grep
- SSH without PuTTY
How to get it
There’s a good chance you already have Git for Windows installed but if not, go ahead and install it with default settings.
Next, download Console2. This comes as a ZIP file which you could extract anywhere. However if you extract it to C:\Program Files (x86)\Console2 then the configs I give you below will work without modification.
Now you have the Bash shell (from Git) running in the Windows terminal and the Windows shell running in the Console2 terminal while what you really want is Bash running in Console2. Configuring this is a bit fiddly so the easiest is to use our sample config and save it as console.xml in the Console2 folder.
Use Ctrl+T to open a new tab and Ctrl+W to close it (same as Chrome/Firefox). In addition to Bash, you can open a Windows shell in a tab with Ctrl+F2. Click and drag to select text then click again to copy it. Right click or Shift+Insert to paste.
It’s also useful to be able to right click on a folder in Windows Explorer and open a shell at that location. Save this somewhere as console2-here.reg then double click it to add the contents to the Windows registry.
Using SSH from the console instead of using PuTTY feels much more integrated but having to type out the full SSH command each time is a pain. To save typing, you can add your commonly accessed servers to ~/.ssh/config
Now instead of typing ssh firstname.lastname@example.org -p2022 you can simply type
ssh ex. SSH config can do lots of other things too.
By default the window title is something like MINGW32:~/current/folder which means your tabs quickly become indistinguishable from each other. Save this file as .profile in your user directory, e.g. C:\Users\Tamlyn Rhodes\.profile, to give your tabs short titles.
You can even use a similar code in the .profile on your server to name your local tab according to your remote directory and server. It’s voodoo but it’s very useful.
Sometimes developing websites on Windows feels like an uphill struggle. Take a few minutes to make these changes and your life will be just a little bit better.