nguyenngoclongdev / vs-terminal-keeper

Elevate your terminal experience! Effortlessly configuration, seamlessly restore your last session, and manage sessions with ease. Personalize your workspace with colorful themes and boost productivity by importing commands swiftly.
https://marketplace.visualstudio.com/items?itemName=nguyenngoclong.terminal-keeper
MIT License
23 stars 3 forks source link

Please add support for relative paths in "cwd" field #3

Closed johnw42 closed 10 months ago

johnw42 commented 1 year ago

It looks like the "cwd" field for a terminalItem only supports absolute paths, at least with PowerShell in Windows. If I try to use a relative path I get a message like this:

The terminal "foo" cannot find the current working directory "bar"

I think it would be helpful to treat relative paths as being relative to the project root.

I can work around the issue by putting a cd command in "commands" and setting "autoExecuteCommands" to true, but then the ability to preload a command without executing it is impaired.

nguyenngoclongdev commented 1 year ago

Hi @johnw42,

Thank you for your feedback. I have released version 1.1.10 to support relative paths in the "cwd" field.

Please upgrade and enjoy the new features. If you encounter any issues, please let me know.

FabioKaelin commented 1 year ago

Hi @nguyenngoclongdev

I noticed that relative paths still don't work. I use v1.1.10 (Linux/Ubuntu and ZSH as Terminal) and I need to always set the entire path (e.g. /home/username/code/project/backend) Does this feature still not work or am I doing something wrong/what value do I have to insert there?

nguyenngoclongdev commented 1 year ago

Hi @FabioKaelin

I tested on Ubuntu 22.04 (terminal-keeper v1.1.10) and it works correctly. image

If you can, please share your terminal-keeper settings?

johnw42 commented 1 year ago

I'm using v1.1.11 and I still can't get the cwd field to work. I've tried in Windows and Ubuntu running in WSL. Here's my session file:

{
  "$schema": "https://cdn.statically.io/gh/nguyenngoclongdev/cdn/main/schema/v8/terminal-keeper.json",
  "theme": "tribe",
  "active": "default",
  "activateOnStartup": false,
  "keepExistingTerminals": true,
  "sessions": {
    "default": [
      {
        "name": "test",
        "autoExecuteCommands": true,
        "cwd": "test",
        "commands": [
          "pwd"
        ]
      },
      {
        "name": "data",
        "autoExecuteCommands": false,
        "cwd": "data",
        "commands": [
          "pwd"
        ]
      }
    ]
  }
}
johnw42 commented 1 year ago

Even if you can't reproduce the problem, I think a good workaround would be to use \n to separate the commands instead of ;. That way I can put a cd command in the command list without it becoming part of the last item in the shell's command history.

nguyenngoclongdev commented 1 year ago

@johnw42 I tried to find the problem and found multiple solutions that can help you. Please try the following: https://stackoverflow.com/questions/52397075/setting-wsl-to-cwd-in-vscode-terminal https://github.com/microsoft/WSL/issues/6995