DEV Community

Luis Ramos
Luis Ramos

Posted on • Originally published at luisramos.dev on

Oh My Zsh prompt theme for Windows Powershell!

I do most of my programming in my mac these days, but once in a while my gaming desktop becomes the testground for some code bashing. Since I use git on the terminal, on windows I use powershell instead of a sweet zsh shell.

Working with powershell is not that bad, but I terribly miss not having the git branches on my prompt. Since I really enjoy the Oh My Zsh theme on my Mac, here’s a snippet that changes your power shell prompt!

function prompt {
\$ESC = [char]27

$p = Split-Path -leaf -path (Get-Location)
  $branch = $(git symbolic-ref -q HEAD) -replace "refs/heads/"
  if ($branch) {
$branch = "$ESC[34mgit:($ESC[0m$ESC[31m$branch$ESC[0m$ESC[34m)$ESC[0m "
}

"$ESC[1m$ESC[32m$([char]0x279C)$ESC[0m $ESC[36m$p$ESC[0m $branch\$ESC[0m"
}

This code lands in the $profile file, which probably needs to be created:

new-item -itemtype file -path $profile -force
notepad $PROFILE

Notepad should open up and you can copy paste the snipped there!

Top comments (1)

Collapse
 
ogaip profile image
Diego Samaniego (ogaip)

Hey there, have you been looking for an alternative to ohmyzsh for Windows? If not, let me show you this. It's called oh-my-posh... ohmyposh.dev/

It works with the new Windows Terminal and there are some nice themes available.

Maybe now you'll miss zsh a little less