Okay, okay, I lied a bit. I can't cover everything that makes a great dev environment in one post— but... I can get you part of the way there with a better terminal.

Let us assume the following scenario:

You're a developer, or maybe you're a designer. On Windows.

Your friends laugh at you whenever you bring up the subject, so you have no idea what it's like to have a streamlined terminal environment with all the bells and whistles that OS level customization and workflow optimization has to offer.

Fear not!

For those of you who can't (or won't) switch, you too can have a reasonably attractive and at least halfway usable terminal environment.

I wrote this post primarily with web development in mind, you software devs out there should probably stick to Cygwin and MinGW. For the most part this post will focus on customizing a console to your needs using lightweight, psuedo-portable tools.

Ready? Great, let's go.

The Final Product

The heart of this setup is a heavily customized ConsoleZ paired with Gnu On Windows and Git Bash. You can actually skip most of the customization and use Cmder instead of ConsoleZ if you're lazy. The text rendering is better for the tradeoff of being noticeably slower.

Getting started

Firstly, if you don't already have it installed, install Git for Windows. Stick with the default options.

Then, grab the latest GOW installer from here. GOW is a straightforward set of common unix command line utilities ported to Windows as portable binaries. Useful stuff.

It will provide you with the standard set of necessities you'd normally have to use third party clients to replicate on Windows, and comprises most of the functionality that this post centers around.

Everything after this point is focused on making these tools nicer to use once they're available to you.

Add the new GOW binaries to your PATH once installed by opening up your command prompt and running the following:

set PATH=%PATH%;C:\Program Files (x86)\Gow\bin

This assumes that the folder you chose to install GOW to was the default location of C:\Program Files (x86)\Gow

If you are unaware of how to get to your prompt, you can do so by doing:

Win + R -> cmd

Doing this will make your fancy new Unix tools available for the rest of your system to use without having to manually type their paths.

Lastly, download ConsoleZ. I chose to create a folder at C:\Program Files\ConsoleZ and place it there, such that it was available at C:\Program Files\ConsoleZ\Console.exe.

Customizing the Console

Git bash has made the use of ~/.bashrc available to you for PS1 customization, you can leave it as-is or use mine as a starting point:

PS1="\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[34m\]Δ\[\033[0m\] \[\033[33m\]\w$(__git_ps1)\[\033[0m\]\nλ "
alias ls='ls --color=auto' # Always use color when displaying the contents of a directory.
alias l.='ls -d .* --color=auto' # Display hidden files
alias nano='nano -$' # Prevent the hard linewrapping that Nano uses by default.

Next come the shortcuts, theming, and shell settings. Open the ConsoleZ preferences with Edit -> Settings and make sure "Save settings to user directory" is checked in the bottom left, and click OK.

Navigate to your settings location with:

Win + R -> %appdata%/Console

Replace your console.xml file with this one.

Additionally, I use a non-default terminal icon which the above theme references. Download it here.

Theming done in one fell swoop. Or two swoops. Who's counting?

Using the Console

Now for the meat of things. The most important aspect of the terminal here is actually non-visible. Namely, the ability to summon the terminal with the tilde key on command for fast terminal reference when you're working in multiple windows. A semi-common feature of Linux terminals, and one that we'll accomplish with AutoHotKey. Download and install the latest.

Or, if you prefer, just download my pre-compiled version of the script. If you trust strange binaries from strangers on the internet, power to you.

The terminal itself has a built in global shortcut listener, but I'd prefer to retain the use of the tilde key as necessary. To get around that we'll have the console use an obscure key combination for the aforementioned global shortcut, and use AutoHotKey to invoke it when we press tilde, retaining the ability to toggle it on and off as necessary.

As a bonus, we can also have it launch the terminal if one is not already running.

I've written a script that accomplishes the above which you can copy paste and then compile yourself:

; # == Win, ^ == Ctrl, + == Shift, ! == Alt

; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; Global Console Toggler
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

; Configuration
toggle_active := true
console_path := "C:\Program Files\ConsoleZ\Console.exe"

; Launch ConsoleZ, disables global shortcuts if already open.
#`::toggle_active := launch("ConsoleZ", console_path, toggle_active)
`::toggle_console("ConsoleZ", toggle_active)

launch(windowName, filePath, toggle_active) {
  DetectHiddenWindows, On
  SetTitleMatchMode 2

  IfWinExist, %windowName%
  {
    toggle_active := !toggle_active
    Return toggle_active
  }

  else
  {
    run %filePath%
    Return true
  }
}

toggle_console(windowName, toggle_active) {
  DetectHiddenWindows, On
  SetTitleMatchMode 2

  if toggle_active {
    Send, ^+``
  }

  else {
    Suspend, On
    SendRaw, ``
    Suspend, Off
  }

  ; Disabled in favor of just using an obscure global hotkey. (Due to unpleasant visual artifacts)
  ; Preserves the simplicity of activating using the tilde key, without the negatives of the below approach.
  ; Uncomment if you would prefer AHK to toggle ConsoleZ itself.
  ;if toggle_active {
  ;  IfWinExist, %windowName%
  ;  {
  ;    IfWinActive, %windowName%
  ;    {
  ;      WinMinimize, %windowName%
  ;    }
  ;    else
  ;    {
  ;      WinActivate, %windowName%
  ;    }
  ;  }
  ;}
}

Usage is very simple:

Win + ` -- Launch terminal if not currently running, toggle tilde capture if currently running.

` -- Show / Hide terminal if script is currently capturing the tilde key.

To make sure that you are always able to use the terminal instantly upon startup, you should compile the above script to a .exe (if you opted to run it manually yourself) and move it to C:\Users\<username>\global_shortcuts.exe.

From there, create a shortcut of global_shortcuts.exe and move it to your startup folder:

Win + R -> %appdata%\Microsoft\Windows\Start Menu\Programs\Startup

And there you have it, a half decent terminal emulator running right within Windows.

Bonus Tips

Use Vagrant!

As a web developer, it is a godsend to have identical dev environments to your contributors. You can take this a step further and work within a fully virtualized system within seconds, for any Git project you own.

Setting up Vagrant is too much to cover in this post, but why settle for an approximation when you can have the real thing?

Add Z to your ~/.bashrc.

Z is a nice little utility that allows you to jump to commonly visited locations without having to type out their full paths every time.

It's as simple as adding something along these lines to your bash config:

. ~/.scripts/z.sh

Back Home
Discourse is fun. Tweet @noisek or ...
Leave A Comment!