Skip to content

Commit eb3ff52

Browse files
Sherry520networm
authored andcommitted
修改附录A:powershell未遵循原文段落格式和翻译约定的问题
1 parent 3d67747 commit eb3ff52

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

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

+33-21
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,82 @@
55
(((posh-git)))
66
Windows 中早期的命令行终端 `cmd.exe` 无法自定义 Git 使用体验,但是如果你正在使用 Powershell,那么你就十分幸运了。
77
这种方法同样适用于 Linux 或 macOS 上运行的 PowerShell Core。
8-
一个名为 Posh-Git (https://github.com/dahlbyk/posh-git[]) 的扩展包提供了强大的 tab 补全功能, 并针对提示符进行了增强,以帮助你聚焦于你的仓库状态。
8+
一个名为 posh-git (https://github.com/dahlbyk/posh-git[]) 的扩展包提供了强大的 tab 补全功能,并针对提示符进行了增强,以帮助你聚焦于你的仓库状态。
99
它看起来像:
1010

11-
.附带了 Posh-Git 扩展包的 Powershell。
12-
image::images/posh-git.png[附带了 Posh-Git 扩展包的 Powershell]
11+
.附带了 posh-git 扩展包的 Powershell。
12+
image::images/posh-git.png[附带了 posh-git 扩展包的 Powershell]
1313

1414
==== 安装
15+
1516
===== 前提需求(仅限 Windows)
16-
在可以运行 PowerShell 脚本之前,你需要将本地的 ExecutionPolicy 设置为 RemoteSigned
17-
(可以说是允许除了 Undefined 和 Restricted 之外的任何内容)。如果你选择了 AllSigned
18-
而非 RemoteSigned,那么你的本地脚本还需要数字签名后才能执行。如果设置为 RemoteSigned,
19-
那么只有ZoneIdentifier设置为 Internet,即从 Web 上下载的脚本才需要签名,其它则不需要。
20-
如果你是管理员,想要为本机上的所有用户设置它,请使用-Scope LocalMachine
21-
如果你是没有管理权限的普通用户,可使用-Scope CurrentUser来只为自己设置它。
17+
18+
在可以运行 PowerShell 脚本之前,你需要将本地的 `ExecutionPolicy` 设置为 `RemoteSigned`(可以说是允许除了 `Undefined``Restricted` 之外的任何内容)。
19+
如果你选择了 `AllSigned` 而非 `RemoteSigned`,那么你的本地脚本还需要数字签名后才能执行。
20+
如果设置为 `RemoteSigned`,那么只有 `ZoneIdentifier` 设置为 `Internet`,即从 Web 上下载的脚本才需要签名,其它则不需要。
21+
如果你是管理员,想要为本机上的所有用户设置它,请使用 `-Scope LocalMachine`
22+
如果你是没有管理权限的普通用户,可使用 `-Scope CurrentUser` 来只为自己设置它。
2223

2324
有关 PowerShell Scopes 的更多详情: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes[]
2425

2526
有关 PowerShell ExecutionPolicy 的更多详情: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy[]
2627

28+
对于所有用户使用以下命令来设置 `ExecutionPolicy` 为 `RemoteSigned`:
29+
2730
[source,powershell]
2831
-----
2932
> Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force
3033
-----
3134

3235
===== PowerShell Gallery
36+
3337
如果你有 PowerShell 5 以上或安装了 PackageManagement 的 PowerShell 4,那么可以用包管理器来安装 posh-git。
3438

3539
有关 PowerShell Gallery 的更多详情: https://docs.microsoft.com/en-us/powershell/scripting/gallery/overview[]
40+
3641
[source,powershell]
3742
-----
3843
> Install-Module posh-git -Scope CurrentUser -Force
3944
> Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force # 带有 PowerShell Core 支持的更新的 beta 版
4045
-----
41-
如果你想为所有的用户安装 posh-git,请使用“-Scope AllUsers”并在管理员权限启动的 PowerShell 控制台中执行。
42-
如果第二条命令执行失败并出现类似 `Module 'PowerShellGet' was not installed by using Install-Module` 这样的错误,
43-
那么你需要先运行另一条命令:
46+
47+
如果你想为所有的用户安装 posh-git,请使用 `-Scope AllUsers` 并在管理员权限启动的 PowerShell 控制台中执行。
48+
如果第二条命令执行失败并出现类似 `Module 'PowerShellGet' was not installed by using Install-Module` 这样的错误,那么你需要先运行另一条命令:
4449

4550
[source,powershell]
4651
----
4752
> Install-Module PowerShellGet -Force -SkipPublisherCheck
4853
----
4954

50-
之后你可以再试一遍。出现这个错误的原因是 Windows PowerShell 搭载的模块是以不同的发布证书签名的。
55+
之后你可以再试一遍。
56+
出现这个错误的原因是 Windows PowerShell 搭载的模块是以不同的发布证书签名的。
5157

5258
===== 更新 PowerShell 提示符
53-
要在你的提示符中包含 Git 信息,那么需要导入 Posh-Git 模块。
54-
要让 PowerShell 在每次启动时都导入 Posh-Git,请执行 Add-PoshGitToProfile 命令,
55-
它会在你的 $profile 脚本中添加导入语句。此脚本会在每次打开新的 PowerShell 终端时执行。
56-
注意,存在多个 $profile 脚本。例如,其中一个是控制台的,另一个则属于 ISE。
59+
60+
要在你的提示符中包含 Git 信息,那么需要导入 posh-git 模块。
61+
要让 PowerShell 在每次启动时都导入 posh-git,请执行 `Add-PoshGitToProfile` 命令,它会在你的 `$profile` 脚本中添加导入语句。
62+
此脚本会在每次打开新的 PowerShell 终端时执行。
63+
注意,存在多个 `$profile` 脚本。
64+
例如,其中一个是控制台的,另一个则属于 ISE。
65+
5766
[source,powershell]
5867
-----
5968
> Import-Module posh-git
6069
> Add-PoshGitToProfile -AllHosts
6170
-----
6271

6372
===== 从源码安装
64-
只需从 (https://github.com/dahlbyk/posh-git[]) 下载一份 Posh-Git 的发行版并解压即可。
65-
接着使用 posh-git.psd1 文件的完整路径导入此模块:
73+
74+
只需从 https://github.com/dahlbyk/posh-git[] 下载一份 posh-git 的发行版并解压即可。
75+
接着使用 `posh-git.psd1` 文件的完整路径导入此模块:
76+
6677
[source,powershell]
6778
-----
6879
> Import-Module <path-to-uncompress-folder>\src\posh-git.psd1
6980
> Add-PoshGitToProfile -AllHosts
7081
-----
7182

72-
它将会向你的 `profile.ps1` 文件添加适当的内容,Posh-Git 将会在下次打开 PowerShell 时启用。
83+
它将会向你的 `profile.ps1` 文件添加适当的内容,posh-git 将会在下次打开 PowerShell 时启用。
84+
7385
命令提示符显示的 Git 状态信息的解释见: https://github.com/dahlbyk/posh-git/blob/master/README.md#git-status-summary-information[]
74-
如何定制 Posh-Git 提示符的详情见: https://github.com/dahlbyk/posh-git/blob/master/README.md#customization-variables[]
86+
如何定制 Posh-Git 提示符的详情见: https://github.com/dahlbyk/posh-git/blob/master/README.md#customization-variables[]

0 commit comments

Comments
 (0)