Skip to content
Keith Hill edited this page Feb 13, 2017 · 4 revisions

Q. I've installed posh-git and I don't see any differences in my prompt, now what?

A. posh-git is a PowerShell module and while many PowerShell modules will be automatically imported when you invoke a command from that module, normal usage of posh-git doesn't require that you invoke any of its commands. In order to enable posh-git's command & branch name tab expansion, you will need to import the posh-git module. And in order to see Git status summary information in your prompt, you will need to define a prompt function in your PowerShell profile. For instructions on how to do this, please read the Customizing your PowerShell Prompt wiki page.

NOTE: In posh-git version 0.7.0 and higher, you will not need to define your own prompt function. Importing posh-git will define a prompt function that displays Git summary status info unless you have already defined a prompt function that you prefer. The wiki topic Customizing your PowerShell Prompt shows several different styles of prompt functions that you can define in your PowerShell profile.


Q. How do I make my posh-git prompt span two lines?

A. In version 0.6.1.x and earlier, you will need to define your own prompt function in your PowerShell profile. For instructions on how to do this, please read the Customizing your PowerShell Prompt wiki page.

NOTE: In posh-git version 0.7.0 and higher, you will be able to override two $GitPromptSettings to cause your prompt to span two lines. Put the following two lines in your PowerShell profile after the Import-Module posh-git command as shown below.

Import-Module posh-git
$GitPromptSettings.PromptSuffix = '`nPS$(''>'' * ($nestedPromptLevel + 1)) ' 
$GitPromptSettings.PromptDebugSuffix = '`n[DBG]: PS$(''>'' * ($nestedPromptLevel + 1)) ' 

Will result in a prompt like:

C:\Users\Keith\GitHub\posh-git [master ≡]
PS>

Q. I'm new to PowerShell, how do I edit my PowerShell profile?

A. You can easily edit your PowerShell profile by executing notepad.exe $profile from the PowerShell prompt. If you are running on Linux or macOS, you can use vi, nano or gedit instead of notepad.

PowerShell supports the following four profile scripts:

AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\<username>\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

When you edit $profile you are editing the profile script specific to the current user and current host. The current host is typically the PowerShell console or perhaps the PowerShell ISE. The point is that host specific profile scripts only run for that host. So if you would prefer to use posh-git in all possible PowerShell hosts, then edit the CurrentUserAllHosts profile like by executing: notepad $profile.CurrentUserAllHosts.

Clone this wiki locally