Configure Windows for Development

March 16, 2019 2 minutes

Environment Variables

I still use some development tools that are used by most Linux users and these tools need some environment variables like LC_ALL, HOME, etc. When I have a new PC with Windows 10, I start to use with defining these variables. Take a look at this post for more detail.

PowerShell Core

It’s possible to use BASH on Windows indeed, but I think PowerShell Core is a good alternative. Git integration is working well, defining aliases and functions is easy:

# Extensions
Import-Module posh-git
Import-Module PSReadLine

# DOSH settings
$env:ENV = "DEV"
Set-Alias dosh .\do.ps1

# Readline settings
Set-PSReadLineOption -EditMode Emacs

# Git prompt settings
$GitPromptSettings.DefaultPromptPath.ForegroundColor = 0xFFA500
$GitPromptSettings.DefaultPromptWriteStatusFirst = $true
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n$([DateTime]::now.ToString("MM-dd HH:mm:ss"))'
$GitPromptSettings.DefaultPromptBeforeSuffix.ForegroundColor = 0x808080
$GitPromptSettings.DefaultPromptSuffix = ' $((Get-History -Count 1).id + 1)$(" >" * ($nestedPromptLevel + 1)) '

# Helper commands
function which ($command) {
    Get-Command $command | Select-Object -ExpandProperty Definition

function touch ($filename) {
    $null > $filename

Readline is a familiar extension for BASH users. If you want to use Emacs key bindings in PowerShell, I suggest you add Readline to the dependencies list.

What if we want to use a Linux command-line app? Like Nano? Indeed, it’s possible to use it as a default git-commit editor but, let’s consider it’s a program that only available in Linux. I use WSL for that case. Just install Ubuntu or another Linux distro with WSL, open PowerShell and run this command:

> wsl -e nano

So you can reach all Ubuntu programs using this magic command. There’s only a little problem here, you have to keep your configuration files (like .nanorc) in your WSL instead of in your local. You can find my configuration repo here.

Git-apply EOL Problem

If you don’t ignore space changes in your patch command, you will get an error because the whitespaces in Linux environments. To solve this problem, use git-apply with these parameters:

$ git apply --ignore-space-change --ignore-whitespace a.diff
comments powered by Disqus