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

Backstory (TLDR)

I work as a full stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

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 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 development for AngularJS, Angular, NodeJS and other spikings in general. I've also done some .NET Core developments 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, Powershell with git, posh-git, oh-my-posh and the Powerline fonts, specifically on how I setup mine which will net you something like the figure below.

Customized Cmder PowerShell with Oh-My-Posh agnoster theme

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.

Prerequisite: Install PowerShellGet

If you are already on Windows 10, you can skip this section.

If not, you will need to make sure you have PowerShellGet installed. We will use it to pull PS Modules from PS Gallery. Instruction on how to get PowerShellGet can be found here.

Installing Chocolatey

I use Chocolatey as my install manager. To install Chocolatey, do the following from within PowerShell:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

PowerShell might complains. If so you probably need to change RemoteSigned to ByPass or Unrestricted. Running Get-ExecutionPolicy from inside PowerShell will tell you what to change it to.

Afterward, run the following and wait for it to finish:

iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

Installing Git using Chocolatey

If you already have git installed, you can skip this part.

Otherwise, run the following to install Git from PowerShell:

cinst git.install -y

Installing Cmder using Chocolatey

If you already have Cmder installed, you can skip this part.

Otherwise, run the following to install Cmder from PowerShell:

cinst cmder -y

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 (stole from here) 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"
}
  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

If you don't see the symbols, please make sure you did the Powerline font installation and Cmder customization as described in section 2.

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