Skip to content

Commit 642104f

Browse files
authored
Merge pull request #1207 from rkeithhill/rkeithhill/update-posh-git-for-pscore
Update for PowerShell Core, module name is all lowercase
2 parents 0823b44 + 4930f90 commit 642104f

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

book/A-git-in-other-environments/sections/powershell.asc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
(((powershell)))(((tab completion, powershell)))(((shell prompts, powershell)))
55
(((posh-git)))
66
The legacy command-line terminal on Windows (`cmd.exe`) isn't really capable of a customized Git experience, but if you're using PowerShell, you're in luck.
7-
This also works if you're running PowerShell on a non-Windows platform like Debian.
8-
A package called Posh-Git (https://github.com/dahlbyk/posh-git[]) provides powerful tab-completion facilities, as well as an enhanced prompt to help you stay on top of your repository status.
7+
This also works if you're running PowerShell Core on Linux or macOS.
8+
A package called posh-git (https://github.com/dahlbyk/posh-git[]) provides powerful tab-completion facilities, as well as an enhanced prompt to help you stay on top of your repository status.
99
It looks like this:
1010

1111
.PowerShell with Posh-git.
@@ -27,16 +27,15 @@ More about PowerShell ExecutionPolicy: https://docs.microsoft.com/en-us/powershe
2727
-----
2828

2929
===== PowerShell Gallery
30-
If you have at least PowerShell 5 or PowerShell 4 with PackageManagement installed, you can use the package manager to fetch Posh-Git for you.
30+
If you have at least PowerShell 5 or PowerShell 4 with PackageManagement installed, you can use the package manager to install posh-git for you.
3131

3232
More information about PowerShell Gallery: https://docs.microsoft.com/en-us/powershell/gallery/overview[]
3333
[source,powershell]
3434
-----
35-
> Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
36-
> Update-Module PowerShellGet -Force
37-
> Install-Module Posh-Git -Scope AllUsers
35+
> Install-Module posh-git -Scope CurrentUser -Force
36+
> Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force # Newer beta version with PowerShell Core support
3837
-----
39-
If you want to install Posh-Git only for the current user and not globally, use "-Scope CurrentUser" instead.
38+
If you want to install posh-git for all users, use "-Scope AllUsers" instead and execute the command from an elevated PowerShell console.
4039
If the second command fails with an error like `Module 'PowerShellGet' was not installed by using Install-Module`, you'll need to run another command first:
4140

4241
[source,powershell]
@@ -48,21 +47,23 @@ Then you can go back and try again.
4847
This happens, because the modules that ship with Windows PowerShell are signed with a different publishment certificate.
4948

5049
===== Update PowerShell Prompt
51-
To include git information in your prompt, posh-git needs to be imported. To do this automatically, include the import statement into you $profile script. This script is executed everytime you open a new PowerShell prompt.
50+
To include git information in your prompt, the posh-git module needs to be imported. To have posh-git imported every time PowerShell starts, execute the Add-PoshGitToProfile command which will add the import statement into you $profile script. This script is executed everytime you open a new PowerShell console.
5251
Keep in mind, that there are multiple $profile scripts. E. g. one for the console and a separate one for the ISE.
5352
[source,powershell]
5453
-----
55-
> New-Item -Name $(Split-Path -Path $profile) -ItemType Directory -Force
56-
> 'Import-Module Posh-Git' | Out-File -Append -Encoding default -FilePath $profile
54+
> Import-Module posh-git
55+
> Add-PoshGitToProfile -AllHosts
5756
-----
5857

5958
===== From Source
60-
Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it to the `WindowsPowerShell` directory.
61-
Then open a PowerShell prompt as an administrator, and do this:
59+
Just download a posh-git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it.
60+
Then import the module using the full path to the posh-git.psd1 file:
6261
[source,powershell]
6362
-----
64-
> cd ~\Documents\WindowsPowerShell\Module\posh-git
65-
> .\install.ps1
63+
> Import-Module <path-to-uncompress-folder>\src\posh-git.psd1
64+
> Add-PoshGitToProfile -AllHosts
6665
-----
6766

68-
This will add the proper line to your `profile.ps1` file, and posh-git will be active the next time you open your prompt.
67+
This will add the proper line to your `profile.ps1` file, and posh-git will be active the next time you open PowerShell.
68+
For a description of the Git status summary information displayed in the prompt see: https://github.com/dahlbyk/posh-git/blob/master/README.md#git-status-summary-information[]
69+
For more details on how to customize your posh-git prompt see: https://github.com/dahlbyk/posh-git/blob/master/README.md#customization-variables[]

images/posh-git.png

10.5 KB
Loading

0 commit comments

Comments
 (0)