Make Windows 10 more Linux like

October 6, 2019 Uncategorized 5 minutes, 42 seconds

Under construction!

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

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. Unfortunatley, 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.

Generally speaking, I always prefer cross platform software to be able to have a 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 usefull Windows applications that are not necessary useful or available on Linux systems:

  • ConEmu - An enhanced terminal featuring tabs, Guake drop down style, various differents shells and much customazation options
  • 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)

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

Good guide to customize and bring color into powershell

  1. Generate new defaut 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
Bash Powershell
ls -ltr Get-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
mkdir New-Item -ItemType Directory -Name ‘NewFolder’
touch{1..4} 1..4 | ForEach-Object { New-Item -ItemType File -Name "MyFile$_" }
tail -n7 ./MyFile1 Get-Content -Tail 7 .\MyFile1
tail -f ./MyFile1 Get-Content -Wait .\MyFile1
grep where-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")

Install PSReadLine (optionally as current user if your 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\\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

To create persistant aliase 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

Requirements:

Pros Cons
normal Linux virtualization overhead
close to native experience hardware passthrough might be an issue
shared folders no gui (at least in headless mode)

Requirements:

  • Enable/Install WSL
  • Choose and install a Linux distribution from. As of now the choice is Ubuntu, OpenSUSE, SLES, Kali Linux, or Debian GNU/Linux. I prefer Ubuntu for the easiest usage
  • [Bonus](https://blog.joaograssi.com/windows-subsystem-for-linux-with-oh-my-zsh-conemu/]

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 (altough possible). Also keep in mind that there might be issues due to differences in both, Windows' and Linux' filessystems.

Pros Cons
Easy Setup Needs admin rights
Close to native Linux Not all distributions available
Your Linux config works Can be slow (emulation)

Requirements:

  • Powershell 4+
Pros Cons
native not Bash
obect oriented awkward commands coming from Linux
Integrated in Windows missing tools

Linux GUI applications usually require a running X Server in order to display their window. You can dowload 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 refered to as an Linux based operationg system like Ubuntu, Arch, Debian 

  2. or CLI, konsole, terminal, you name it  

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