Tyriar / vscode-windows-terminal

VS Code integration with Windows Terminal
https://marketplace.visualstudio.com/items?itemName=Tyriar.windows-terminal
MIT License
33 stars 8 forks source link

Terminal is not opened in the correct directory (WSL) #14

Closed warpdesign closed 4 years ago

warpdesign commented 4 years ago

How to reproduce?

What happens?

Windows Terminal is opened in ~

What should happen?

Windows Terminal should be opened in the file's folder instead.

Details

Note: that this may be related to https://github.com/microsoft/terminal/issues/6022

Note 2: the same happens when right-clicking on Open in Terminal: the integrated terminal is opened in~ instead of the file's folder.

Tyriar commented 4 years ago

Strange, it sounds like it is because of https://github.com/microsoft/terminal/issues/6022. Works fine in my Debian distro.

warpdesign commented 4 years ago

Strange, it sounds like it is because of microsoft/terminal#6022. Works fine in my Debian distro.

Since it also happens with the Open in Terminal option (which has nothing to do with Windows Terminal), isn't it related to WSL instead?

Tyriar commented 4 years ago

@warpdesign either that or WSL, I'm a little suspicious of "source": "Windows.Terminal.Wsl" in the WT profile as I'm not sure how that's working.

warpdesign commented 4 years ago

I am closing the issue: latest Ubuntu release has this at the end of .bashrc:

cd ~

So it was actually working but directory was changed to user's home because of this.

Removing this line obviously fixes the problem.

Tyriar commented 4 years ago

🤦

jakebrinkmann commented 4 years ago

If someone else arrives here, it can also happen if you have your WT settings.json profile configured to start in the home directory:

"profiles":
    [
        {
            "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
            "hidden": false,
            "name": "Ubuntu-18.04",
            "source": "Windows.Terminal.Wsl",
            //"commandline": "wsl.exe ~"
        }
    ],
MaRo99382 commented 2 months ago

I have the same issue as @warpdesign did in 2020. Opening a directory or file in Visual Studio Code with the "Open in Windows Terminal (Profile)" feature always starts Windows Terminal in my home directory. I have the following Windows Terminal Profile with no command line:

           {
                "colorScheme": "Campbell",
                "guid": "{51855cb2-8cce-5362-8f54-464b92b32386}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc"
            },

And in my VS Code settings.json I have

    "terminal.explorerKind": "external",
    "terminal.external.windowsExec": "wt"

My .bashrc does not contain a cd ~ or any other cd command. Maybe this issue is related to the fact, that with these settings, when I use the "Open in Terminal" context menu, it also does not open the external Windows Terminal but still the integrated terminal. Any help is appreciated.