Cia*_*lsh 3 powershell windows-subsystem-for-linux
我可以打开 powershell 并输入
> Ubuntu
Run Code Online (Sandbox Code Playgroud)
在 Windows 10 上打开 WSL ubuntu shell。这将始终将我带到 WSL 主目录。我该如何在 powershell 当前所在的同一位置打开终端?
供参考。我需要这个来为 Windows 资源管理器创建右键单击“在此处打开终端”类型的注册表项。
Roa*_*ner 10
如果我们看看跑步ubuntu.exe实际上做了什么:
PS C:\> ubuntu.exe /?
Launches or configures a Linux distribution.
Usage:
<no args>
Launches the user's default shell in the user's home directory.
install [--root]
Install the distribution and do not launch the shell when complete.
--root
Do not create a user account and leave the default user set to root.
run <command line>
Run the provided command line in the current working directory. If no
command line is provided, the default shell is launched.
config [setting [value]]
Configure settings for this distribution.
Settings:
--default-user <username>
Sets the default user to <username>. This must be an existing user.
help
Print usage information.
Run Code Online (Sandbox Code Playgroud)
我们可以看到它默认在主目录中启动 WSL shell 。如果我们想在 PowerShell 中打开的当前目录中运行,我们需要指定该run选项。所以完整的命令是ubuntu.exe run.
另一种选择是只运行wsl.exe或bash.exe。默认情况下,这些命令将在当前工作目录中打开 WSL。
注意:我们不需要.exe在命令后面指定。运行ubuntu,wsl一切bash正常。PowerShell 知道如何在不指定扩展名的情况下运行可执行文件。
小智 7
方法一:
wsl --set-default Ubuntu方法2:
打开其他文件夹
wsl.exe --cd $pwd或者wsl.exe --cd "path"| 归档时间: |
|
| 查看次数: |
18408 次 |
| 最近记录: |