如何在当前 powershell 目录中启动 WSL 终端?
How to start WSL terminal in a current powershell directory?
我可以打开电源shell然后输入
> Ubuntu
在 windows 10 上打开 WSL ubuntu shell。这将始终带我到 WSL 主目录。我将如何在 powershell 当前所在的相同位置打开终端?
仅供参考。我需要它来为 windows 资源管理器创建右键单击 "open terminal here" 类型的注册码。
如果我们看看 运行ning 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.
我们可以看到它默认在 主目录 中启动 WSL shell。如果我们想要 运行 在 PowerShell 中打开的当前目录中,我们需要指定 run
选项。所以完整的命令将是 ubuntu.exe run
.
另一种选择是 运行 wsl.exe
或 bash.exe
。默认情况下,这些命令将在当前工作目录中打开 WSL。
注意:我们不需要在命令后指定.exe
。 运行 ubuntu
、wsl
和 bash
也都有效。 PowerShell 知道如何在不指定扩展名的情况下 运行 可执行文件。
方法一:
- 通过
wsl --set-default Ubuntu
将Ubuntu设置为wsl默认分发
- 只需键入 wsl,您就在当前的 Powershell 目录中
方法二:
打开其他文件夹
wsl.exe --cd $pwd
或 wsl.exe --cd "path"
我可以打开电源shell然后输入
> Ubuntu
在 windows 10 上打开 WSL ubuntu shell。这将始终带我到 WSL 主目录。我将如何在 powershell 当前所在的相同位置打开终端?
仅供参考。我需要它来为 windows 资源管理器创建右键单击 "open terminal here" 类型的注册码。
如果我们看看 运行ning 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.
我们可以看到它默认在 主目录 中启动 WSL shell。如果我们想要 运行 在 PowerShell 中打开的当前目录中,我们需要指定 run
选项。所以完整的命令将是 ubuntu.exe run
.
另一种选择是 运行 wsl.exe
或 bash.exe
。默认情况下,这些命令将在当前工作目录中打开 WSL。
注意:我们不需要在命令后指定.exe
。 运行 ubuntu
、wsl
和 bash
也都有效。 PowerShell 知道如何在不指定扩展名的情况下 运行 可执行文件。
方法一:
- 通过
wsl --set-default Ubuntu
将Ubuntu设置为wsl默认分发
- 只需键入 wsl,您就在当前的 Powershell 目录中
方法二:
打开其他文件夹
wsl.exe --cd $pwd
或wsl.exe --cd "path"