Skip to main content
Make Windows 10 more Linux like

Make Windows 10 more Linux like

·1140 words·6 mins·
workflow configuration
Table of Contents

Motivation
#

I am a Linux1 user for over a decade and my workflow and productivity is optimized to this environment especially the shell2. For some insights of my workflow and tools have a look at here. From time to time my work demands from me to work on a Windows machine despite the fact that in my kind of business, Infrastructure and DevOps, the majority of systems and tools is Linux driven.

Now the question is how to get the best Linux like experience on a Windows 103 machine specifically how to get the best shell experience and the tools that I am used to.

I want to describe some Windows tweaks and three ways of getting a more Linux like experience on your Windows 10 machine as follows:

  1. A combination of a virtual machine running Linux and a local SSH client
  2. The Windows Subsystem for Linux basically a compatibility layer for running linux binaries (ELF)
  3. Tweak and enhance the Powershell

Built-in Windows Tools
#

Windows 10 finally has built-in functionality that is available on Linux since my beginning: virtual desktops and a clipboard manager!

You can access the clipboard manager by pressing Win + v. Although it is not as powerful as some Linux managers it is a start. Also have a look at ditto for a replacement.

Virtual desktops are crucial for my workflow! I use them to structure my apps and keep my applications organized on different desktops. Unfortunately, the shortcuts for interacting with virtual desktops are not customizable out of the box. Virtual Desktop Enhancer fills the gap and allows me to create more “home row friendly” shortcuts.

Software
#

Generally speaking, I always prefer cross-platform software to be able to have an as much as possible unified user experience across different platforms. That said have a look at my CLI Applications and GUI Applications summaries. Particularly, most of the GUI applications I am running are cross platform capable. Nevertheless, find some useful Windows applications that are not necessary useful or available on Linux systems:

  • ConEmu - An enhanced terminal featuring tabs, Guake drop down style, various different shells and much customization options
  • Terminus - Alternative to ConEmu, configurable, includes patched fonts, integrated SSH client, Powershell, WSL, CMD and more
  • MobaXterm - A fully featured SSH, FTP, RDP and more client with session management, tunneling, its own shell and more
  • Autohotkey - An open source Windows scripting tool for automation and key binding settings for instance mapping ESC to CAPS.
  • Virtual Desktop Enhancer - Customizing shortcuts for built-in virtual desktops
  • ditto - A free clipboard manager for those that want more customization than the built-in one offers
  • PowerToys - Tools from Microsoft for power users
  • WinFile - Original Microsoft Windows file manager (very fast, no special folders)

Autohotkey
#

To automatically start an AHK script simply add capstoesc.ahk to your Windows startup folder (Win+r -> shell:startup)

Powershell
#

Good guide to customize and bring color into Powershell

  1. Generate new default profile for Powershell
new-item $profile -itemtype file -force
  1. Edit profile
ise $PROFILE
  1. Different profiles

There are six different profiles

| Current User, Current Host – console | $Home[My ]Documents\WindowsPowershell\Profile.ps1 | All Users, Current Host – console | $PsHome\Microsoft.Powershell_profile.ps1

  1. Bash -> Powershell
BashPowershell
ls -ltrGet-ChildItem . | Sort-Object -Property LastWriteTime
find . -type f -iname “azure”Get-ChildItem -Filter “azure” -Recurse -File
cp -R Tools ~/Copy-Item ‘.\Tools' $env:USERPROFILE -Recurse
mkdirNew-Item -ItemType Directory -Name ‘NewFolder’
touch{1..4}1..4 | ForEach-Object { New-Item -ItemType File -Name “MyFile$_” }
tail -n7 ./MyFile1Get-Content -Tail 7 .\MyFile1
tail -f ./MyFile1Get-Content -Wait .\MyFile1
grepwhere-object and select-string -pattern
redirect output*>&1 > log.txt
  1. Environment
  • List environment Get-ChildItem Env:s
  • See Env for current session Get-ChildItem Env:*path* | format-list or $env:path
  • Set env for current session $env:myX = "alice" or $env:path = $env:path + ";C:\Program Files (x86)\app\bin"
  • Remove env for current session Remove-Item env:myX
  • See Permanent Env variable [environment]::GetEnvironmentVariable("myY", "[User|Process|Machine]")
  • Create permanent Env variable [Environment]::SetEnvironmentVariable("myY", "la la", "User")
  • Removing Permanent Env variable [Environment]::SetEnvironmentVariable("myY", $null, "User")

Powershell extensions
#

Install PSReadLine (optionally as current user if you are lacking admin rights). PSReadLine provides several features which are known from bash like a history search, undo/redo, and more.

Install-Module [-Scope CurrentUser] PSReadLine

Add Import-Module PSReadLine to C:\Users\<user>\Documents\WindowsPowershell\Microsoft.PowerShell_profile.ps1 (create file if necessary) to autoload the module upon Powershell start.

Set keybinding to Emacs to use common bash key combos, e.g. ctrl+a for jumping to the beginning of the line

Set-PSReadlineOption -EditMode Emacs

Enable history search forward/backward auto-completion with

Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
  • posh-git for Powershell Git integration: Install-Module posh-git Import-Module posh-gitto your Powershell Profile
  • posh-docker for Docker completion: Install-Module posh-docker and add Import-Module posh-docker to your Powershell Profile

Aliases
#

To create persistent aliases create the file C:\Users\<user>\Documents\WindowsPowershell\Microsoft.PowerShell_profile.ps1 (folder might not exist).

You might have to allow the execution of Powershell scripts on your system: Set-ExecutionPolicy -Scope CurrentUser BYPASS

keep security policies in mind

function f_workspace {Set-Location "C:\Users\<user>\Documents\workspace"}
Set-Alias workspace f_workspace
function f_up {docker-compose.exe up }
Set-Alias dup f_up
function f_images {docker images}
Set-Alias di f_images
function f_ps {docker ps}
Set-Alias dps f_ps
function f_dexec {docker exec -it}
Set-Alias dexec f_dexec

VM + SSH Client
#

Requirements:

ProsCons
normal Linuxvirtualisation overhead
close to native experiencehardware pass through might be an issue
shared foldersno GUI (at least in headless mode)

WSL
#

Requirements:

Basically, configure it like your Linux. Install zsh, clone your dotfiles, install tools like ripgrep, fzf, etc. Generally speaking WSL is intended to be used to access Linux toolchain and not for server or GUI applications (although possible). Also keep in mind that there might be issues due to differences in both, Windows’ and Linux’ file system.

ProsCons
Easy SetupNeeds admin rights
Close to native LinuxNot all distributions available
Your Linux config worksCan be slow (emulation)

Powershell
#

Requirements:

  • Powershell 4+
ProsCons
nativenot Bash
object orientedawkward commands coming from Linux
Integrated in Windowsmissing tools

Start Linux GUI Applications in Winodws
#

Linux GUI applications usually require a running X Server in order to display their window. You can download some X server implementation for Winodws like Xming. After installing and starting the x server on your Windows machine you just enter export DISPLAY=:0 in your WSL. Now you can launch GUI applications within this WSL shell.


  1. Linux is referred to as an Linux based operations system like Ubuntu, Arch, Debian ↩︎

  2. or CLI, console, terminal, you name it ↩︎

  3. WSL is only available on Windows 10 64bit systems ↩︎