Windows powershell:更改默认工作目录

时间:2021-02-22 16:12:02

标签: powershell

每次打开 Windows PowerShell 时,我都需要 cd 到特定文件夹。

有没有办法在powerShell参数中配置它(例如我在考虑参数Json)?

我发现 set-location 很有用。我在参数 json 中尝试了 "Set-Location": "c:/",但似乎不起作用。

有什么想法吗?

在 thom schumacher 评论后更新: 我想我已经有了一个个人资料,我对第一个感兴趣:(我的参数 json 的一部分)

 "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
        },
        "list":
        [
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory":"//wsl$/Ubuntu-20.04/home/vmelin",
                "colorScheme": "Solarized Dark",
                "fontFace": "Cascadia Code PL"
            },
...

在此配置文件中添加 "Set-Location": "/home/aalidra" 没有成功。

谢谢

1 个答案:

答案 0 :(得分:1)

看看这篇关于 Powershell 配置文件的文章。如果你添加了一个配置文件,那么你可以添加你想要的 CD: PowerShell Profiles