You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/A-git-in-other-environments/sections/powershell.asc
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,16 +15,18 @@ image::images/posh-git.png[PowerShell with Posh-git.]
15
15
16
16
===== Prerequisites (Windows only)
17
17
18
-
Before you're able to run PowerShell scripts on your machine, you need to set your local ExecutionPolicy to RemoteSigned (Basically anything except Undefined and Restricted).
19
-
If you choose AllSigned instead of RemoteSigned, also local scripts (your own) need to be digitally signed in order to be executed.
20
-
With RemoteSigned, only Scripts having the "ZoneIdentifier" set to Internet (were downloaded from the web) need to be signed, others not.
21
-
If you're an administrator and want to set it for all Users on that machine, use "-Scope LocalMachine".
22
-
If you're a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you.
18
+
Before you're able to run PowerShell scripts on your machine, you need to set your local `ExecutionPolicy` to `RemoteSigned` (basically, anything except `Undefined` and `Restricted`).
19
+
If you choose `AllSigned` instead of `RemoteSigned`, also local scripts (your own) need to be digitally signed in order to be executed.
20
+
With `RemoteSigned`, only scripts having the `ZoneIdentifier` set to `Internet` (were downloaded from the web) need to be signed, others not.
21
+
If you're an administrator and want to set it for all users on that machine, use `-Scope LocalMachine`.
22
+
If you're a normal user, without administrative rights, you can use `-Scope CurrentUser` to set it only for you.
23
23
24
24
More about PowerShell Scopes: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes[]
25
25
26
26
More about PowerShell ExecutionPolicy: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy[]
27
27
28
+
To set the value of `ExecutionPolicy` to `RemoteSigned` for all users use the next command:
@@ -42,7 +44,7 @@ More information about PowerShell Gallery: https://docs.microsoft.com/en-us/powe
42
44
> Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force # Newer beta version with PowerShell Core support
43
45
----
44
46
45
-
If you want to install posh-git for all users, use "-Scope AllUsers" instead and execute the command from an elevated PowerShell console.
47
+
If you want to install posh-git for all users, use `-Scope AllUsers` instead and execute the command from an elevated PowerShell console.
46
48
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:
47
49
48
50
[source,powershell]
@@ -56,9 +58,9 @@ This happens, because the modules that ship with Windows PowerShell are signed w
56
58
===== Update PowerShell Prompt
57
59
58
60
To include git information in your prompt, the posh-git module needs to be imported.
59
-
To have posh-git imported every time PowerShell starts, execute the Add-PoshGitToProfile command which will add the import statement into you $profile script.
61
+
To have posh-git imported every time PowerShell starts, execute the `Add-PoshGitToProfile` command which will add the import statement into you `$profile` script.
60
62
This script is executed everytime you open a new PowerShell console.
61
-
Keep in mind, that there are multiple $profile scripts.
63
+
Keep in mind, that there are multiple `$profile` scripts.
62
64
E. g. one for the console and a separate one for the ISE.
63
65
64
66
[source,powershell]
@@ -69,8 +71,8 @@ E. g. one for the console and a separate one for the ISE.
69
71
70
72
===== From Source
71
73
72
-
Just download a posh-git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it.
73
-
Then import the module using the full path to the posh-git.psd1 file:
74
+
Just download a posh-git release from https://github.com/dahlbyk/posh-git/releases[], and uncompress it.
75
+
Then import the module using the full path to the `posh-git.psd1` file:
74
76
75
77
[source,powershell]
76
78
----
@@ -79,5 +81,6 @@ Then import the module using the full path to the posh-git.psd1 file:
79
81
----
80
82
81
83
This will add the proper line to your `profile.ps1` file, and posh-git will be active the next time you open PowerShell.
84
+
82
85
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[]
83
86
For more details on how to customize your posh-git prompt see: https://github.com/dahlbyk/posh-git/blob/master/README.md#customization-variables[]
For more information on vcs_info, check out its documentation
44
-
in the `zshcontrib(1)` manual page,
45
-
or online at http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information[].
43
+
For more information on `vcs_info`, check out its documentation in the `zshcontrib(1)` manual page, or online at http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information[].
46
44
47
-
Instead of vcs_info, you might prefer the prompt customization script that ships with Git, called `git-prompt.sh`; see https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh[] for details.
45
+
Instead of `vcs_info`, you might prefer the prompt customization script that ships with Git, called `git-prompt.sh`; see https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh[] for details.
48
46
`git-prompt.sh` is compatible with both Bash and Zsh.
49
47
50
48
Zsh is powerful enough that there are entire frameworks dedicated to making it better.
@@ -53,5 +51,5 @@ oh-my-zsh's plugin system comes with powerful git tab-completion, and it has a v
53
51
<<oh_my_zsh_git>> is just one example of what can be done with this system.
54
52
55
53
[[oh_my_zsh_git]]
56
-
.An example of an oh-my-zsh theme.
54
+
.An example of an oh-my-zsh theme
57
55
image::images/zsh-oh-my.png[An example of an oh-my-zsh theme.]
0 commit comments