As generalists, we can and do work across many platforms and frameworks. But that doesn’t mean that we’re immediately comfortable when we have to pack up and move from the platform we typically call home, where we’ve got things arranged just the way we like it.
When moving from a Unix-like platform to Windows, things can feel uncomfortable. Some people try (with varying success) to reproduce their home platform by installing a complete Unix-like environment to sit atop Windows. Instead of doing that, I decided to see how I could stay close to Windows and make using its own command line more comfortable.
PowerShell Pain Points
We’ll primarily be working in Windows’s PowerShell. It’s definitely not Unix’s Z shell, but it is a powerful tool that has deep integrations into the Windows platform.
However, there are a few problems when using it interactively out of the box:
- It’s hard to quickly add new tools to your toolbox. Going to a website, downloading an installer, running it, and clicking through all of its prompts is tedious, and this process might discourage you from trying new tools.
- It’s painful to look at. It’s not exaggerating to say that its harsh white-on-blue color scheme becomes impossible to read once you start using commands that have color output.
- Using it feels strange. Its default tab completion implementation grabs the first match, and, when navigating directories, it’s awkward to dive into a deep tree.
- Tools aren’t as well-integrated as they could be. For example, I quickly tired of typing Git branch names, which were completed for me over on my macOS terminal.
Managing Software with Scoop
The very first thing you’ll need to start with is a tool called Scoop. I’ve been using it for so long that it turns out I’ve already written about it.
Since then, though, I’ve also been contributing software information to the Scoop project through app manifests. Creating them is really easy, and I was able to contribute a manifest to the extras bucket for Service Bus Explorer, easing my team’s (and others’) ability to install that software.
So get Scoop installed, and grab a few of your favorite programs (like Vim, Git, and Ag, all of which are readily available in Scoop).
A More Pleasant Theme with concfg
To get out from under PowerShell’s painful display defaults, you can use a tool (also maintained by Scoop’s author) called concfg. Fair warning, I’ve had some trouble with its theme support, but it’s really good for one thing: its
After installing it from Scoop, run:
This removes the white-on-blue scheme and poor font choice from PowerShell so that next time you run it, you get a more standard grey-on-black scheme. Now Git’s color diffs will actually be something you can see.
You can improve it even more by installing the Fira Code font and using my own pastel configuration, based on iTerm2’s.
Better Tab Completion with PSReadline
I could never get the hang of PowerShell’s default tab completion, and I’ve seen it drive people away from using PowerShell. Luckily, you don’t have to stick with that default implementation.
A project called PSReadline (already installed in Windows 10) can be configured to add Readline-style tab completions to your shell. Just issue this command:
Set-PSReadlineKeyHandler -Key Tab -Function Complete
In my experience, it’s unfortunately not as fast as Bash under macOS, but it’s significantly more comfortable than the default setup.
To get this to fire up every time you open PowerShell, add it to your profile. You can get PowerShell to tell you where that is by issuing this command:
Create this file in your favorite text editor, and you can add any startup commands you wish, including the above.
Git Better with posh-git
Once I had functional and usable tab completion, the fact that Git couldn’t complete branch names was really starting to annoy me. Thankfully, there was a package in Scoop for that, in addition to some other convenient Git/PowerShell integration features.
This PowerShell module is called posh-git, and you can
scoop install it just like anything else. Once it’s in, you can activate it for the current session like this:
After you import it, you’ll see your prompt expand once you’re inside a Git working copy, showing your current branch and a few other useful indicators. You’ll also find that you can autocomplete Git commands, branch names, and other handy things.
If you like it, add it to your profile as above.
Improving my development environment is an ongoing effort. I’m sure I’ll find more sore points and more opportunities to improve it as time goes on. I’d love to hear what you’re doing to make PowerShell a more hospitable place.