Search code examples
gitpowershellposh-git

Why does my Posh-Git prompt keep disappearing?


I've always used Phil Haack's method of installing Posh-Git, with the following PowerShell commands:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
install-module posh-git

The first line installs PsGet, and the second Post Git. I've also just tried install-module posh-git, having installed PsGet.

What happens is that the Post-Git prompt shows in the same PS Window I installed it in, but when I close that window and open another, Post-Git seems gone again.

This is a new machine, with a new Windows 10 Pro. Posh-Git worked on my old one, also with Windows 10 Pro, the only difference I know is the new one is SSD, and that shouldn't affect any of this.


Solution

  • It seems that you are confusing Installing a module (Install-Module) with loading (importing) a module (Import-Module).

    To import your module on every start of PowerShell:

    ...either create a prepared shortcut with a command line like %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -Command Import-Module posh-git

    ...or use PowerShell profiles.

    I'd prefer the latter if you plan to import several modules (maybe based on special conditions). Please keep in mind anyway, that loading a heavy profile will affect your PowerShells startup performance.