Update 20221022.3 ️ Use open source commands in Powershell.md

This commit is contained in:
qfzy1233 2022-10-29 14:15:44 +08:00
parent c9dbc5bf48
commit dc11ebd517

View File

@ -7,27 +7,26 @@
[#]: publisher: " "
[#]: url: " "
Use open source commands in Powershell
在Powershell 中使用开源命令
======
When you launch an application on an operating system, there are certain code libraries and utility applications that your OS needs to use for that app to run. Your OS knows how to find these libraries and utilities because it has a _system path,_ a map to common shared data that lots of apps need. Every OS has this, but users arent usually aware of it because they dont usually need to care about it. However, when you start coding or using special network utilities or commands, you might care about your own PATH variable.
当你在操作系统上启动应用程序时操作系统需要使用某些代码库和实用程序来运行该应用程序。你的操作系统知道如何找到这些库和实用程序因为它有一个_系统路径_一个到许多应用程序都需要用到的公共共享数据的映射。所有操作系统都有这一点但用户通常不会意识到这一点因为他们通常不需要在意它。然而当你需要编程或使用特殊的网络实用程序或命令时你可能需要关心你自己的PATH变量配置。
The PATH variable makes it so that you can save commands to a consistent location, and use them from anywhere on your system using the command prompt or the more powerful (and open source) [Powershell][1].
PATH变量使你可以将命令保存到一致的位置并使用命令提示符或更强大(也是开源的)[Powershell][1]从系统上的任何位置调用它们。
For instance, say you want to install the open source application `pscp.exe`, a command-line interface to the famous PuTTY OpenSSH client on Windows. You can download it to your hard drive, but how does your command-line know that it exists? Well at first, it doesnt:
例如假设你想安装开源应用程序“pscp.exe”它是Windows上著名的PuTTY OpenSSH客户端的命令行界面。你可以将它下载到你的硬盘但是你的命令行如何知道它的存在呢?实时一开始,它并不知道:
```
PS> pscp
pscp: The term 'pscp' is not recognized as the name of a cmdlet, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
pscp: 命令“pscp”不能被识别为cmdlet、脚本文件或可操作程序的名称。检查名称的拼写或者如果包含了路径则检查路径是否正确然后再试一次。
```
If youre using an open source command line, such as Powershell or [Cmder][2], you get a useful error hinting that this might be a problem with your path (or the lack thereof). Heres how to solve that problem.
如果你正在使用一个开源命令行例如Powershell或[Cmder][2],那么你将得到一个有用的错误提示,提示这可能是你的路径有问题(或没有问题)。下面是解决这个问题的方法。
### Setting a PATH
### 设置 PATH
- First, create a folder called `App` on your Desktop.
- Next, right-click on the Windows menu in the bottom left corner of your screen, and select **System**.
- 首先,在桌面上创建一个名为`App`的文件夹。
- 接下来右键单击屏幕左下角的Windows菜单然后选择 **系统**.
![Image of the Windows menu system.][3]
@ -35,8 +34,8 @@ Image by:
(Alan Smithee, CC BY-SA 4.0)
- In the **System** window that appears, click the link to **Advanced system settings** on the left of the window.
- In the **System properties** window that appears, click the **Environment variables** button at the bottom of the window.
- 在弹出的“**系统**”窗口中,单击窗口左侧的“**高级系统设置**”链接。
- 在出现的**系统属性**窗口中,单击窗口底部的**环境变量**按钮。
![Image Windows system enviroment variables.][4]
@ -44,7 +43,7 @@ Image by:
(Alan Smithee, CC BY-SA 4.0)
- In the **Environment variables** window, click the **New** button under the **User variables** panel.
- 在**环境变量**窗口中,单击**用户变量**面板下的**新建**按钮。
![Image of new Windows enviroment variables.][5]
@ -52,7 +51,7 @@ Image by:
(Alan Smithee, CC BY-SA 4.0)
- In the dialog box that appears, enter `PATH` for the **Variable name** field, and `%USERPROFILE\Desktop\App` for the **Variable value** field. Click the **OK** button to save your changes.
- 在弹出的对话框中,为**变量名**字段输入`PATH`,为**变量值**字段输入 `%USERPROFILE\Desktop\App` 。单击**OK**按钮保存更改。
![Image of Windows path set.][6]
@ -60,7 +59,7 @@ Image by:
(Alan Smithee, CC BY-SA 4.0)
Place commands and applications you want to have access to from a command prompt in `Desktop\Apps` and Powershell, Cmder, and even Cmd will find them:
将那些你希望从命令提示符在`Desktop\Apps`和Powershell, CmderCmd中调用的命令和应用程序放置于`Desktop\Apps`路径下:
```
PS> pscp version
@ -69,9 +68,9 @@ PS> pscp version
PS>
```
### Automatic PATH settings
### PATH路径自动设置
Many applications get automatically added to the system path during installation. However, not all of them do, either because you missed a check box during the install process, or because the application developer expects you to add it yourself. When automatic paths fail, you now know how to forge your own path.
许多应用程序会在安装过程中自动添加到系统路径中。然而,并不是所有的程序都如此,要么是因为你在安装过程中遗漏了一个复选框,要么是因为应用程序开发人员希望你自己添加它。当自动路径失败时,你现在知道如何自己设置路径。
--------------------------------------------------------------------------------