gpt4 book ai didi

powershell - 如何在当前Powershell目录中启动WSL终端?

转载 作者:行者123 更新时间:2023-12-03 01:27:39 28 4
gpt4 key购买 nike

我可以打开Powershell并输入

> Ubuntu 

在Windows 10上打开WSL ubuntu shell。这将始终把我带到WSL主目录。我该如何在Powershell当前所在的位置打开终端?

仅供引用。我需要创建一个右键单击“在此处打开终端”类型的Windows资源管理器注册键。

最佳答案

如果我们看看正在运行的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 distribuiton 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.exebash.exe。默认情况下,这些命令将在当前工作目录中打开WSL。

注意:我们不需要在命令后指定 .exe。运行 ubuntuwslbash都可以正常工作。 PowerShell知道如何在不指定扩展名的情况下运行可执行文件。

关于powershell - 如何在当前Powershell目录中启动WSL终端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61055196/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com