Chris's coding blog

Change your Powershell prompt to look like bash

February 23, 2017

The script below changes your Powershell prompt to look a bit more like a Bash one. Update your ~Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 file to add the code below. If you aren’t using poshgit then remove the Import-Module and Write-VcsStatus lines.

Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-7d93c81\src\posh-git.psd1' function prompt { # Shorten the path $path = $ExecutionContext.SessionState.Path.CurrentLocation.Path $path = $path.Replace($HOME, "~") Write-Host "$path" -ForegroundColor Green -NoNewline Write-VcsStatus Write-Host "" "$('$' * ($nestedPromptLevel + 1)) " }

Your Powershell command prompt will now look something like this:

~\Documents\Code\Github\yetanotherchris.github.io\_posts [master ≡] $ echo "hello world"
powershellbash

I'm Chris Small, a software engineer working in London. This is my tech blog. Find out more about me via GithubStackoverflowResume