Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yadianfdez07/6a62114d8b34bf9115aa20e95b95ead0 to your computer and use it in GitHub Desktop.

Select an option

Save yadianfdez07/6a62114d8b34bf9115aa20e95b95ead0 to your computer and use it in GitHub Desktop.
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Nice Front-End / Node Development Environment on Windows 10 Setup with VS Code, Cmder, PowerShell, Posh-Git, Oh-My-Posh, and Powerline Fonts

I work as a full stack developer using Windows environment. For my console need, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice, being on Windows and all (Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows). If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

For source control, I use git for my spikes since our main source control at work is still using the hosted TFS on Visual Studio Team Services.

My editor of choice nowadays is VS Code which is lightweight, customizable and all around a good environment to do front-end development in. I've also done some .NET Core development on the editor which is supported quite well including debugging if you follow that style of development. VS Code customization is a large topic by itself, so I won't be writing about it here. Perhaps some other time.

For now, we'll focus on customizing Cmder / ConEmu Powershell with git, posh-git, oh-my-posh and the Powerline fonts. Specifically on how I setup mine.

A lot of people has written up about customizing PowerShell but I can only find bits and pieces. This article hopefully will combine those bits and pieces into a more coherent end-to-end story.

PowerShell Version Prerequitsite

Install Posh-Git and Oh-My-Posh

Installation instruction here...

Set-Theme agnoster

Install Powerline Fonts

Clone the powerline repository from GitHub.

git clone https://github.com/powerline/fonts.git

afterward, do the following:

cd fonts
.\install.ps1

Wait for all the fonts to be installed.

Select the Font You Want to Use from Cmder / ConEmu

From inside Cmder / ConEmu settings dialog, ensure you choose the powerline font you wish to used. i.e. Menslo ... for Powerline, etc. Also make sure you set the same font for the Alternative font to use, otherwise some characters will not show.

How to test if Powerline is correctly installed in Cmder / ConEmu:

  1. Add the following function to your powerline $PROFILE. To edit your $PROFILE, just run ise $PROFILE from within PowerShell:
function U
{
    param
    (
        [int] $Code
    )
 
    if ((0 -le $Code) -and ($Code -le 0xFFFF))
    {
        return [char] $Code
    }
 
    if ((0x10000 -le $Code) -and ($Code -le 0x10FFFF))
    {
        return [char]::ConvertFromUtf32($Code)
    }
 
    throw "Invalid character code $Code"
}

stole from here.

  1. Run the following script inside PowerShell:
Write-Host "$(U 0xE0B0) $(U 0x00B1) $(U 0xE0A0) $(U 0x27A6) $(U 0x2718) $(U 0x26A1) $(U 0x2699)"

You should see something like the second line in the figure below: Git Characters

Research References

https://gist.github.com/agnoster/3712874

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment