Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow split terminal to inherit working directory from previous terminal #48447

Closed
octref opened this issue Apr 23, 2018 · 14 comments · Fixed by #60949
Closed

Allow split terminal to inherit working directory from previous terminal #48447

octref opened this issue Apr 23, 2018 · 14 comments · Fixed by #60949
Assignees
Labels
feature-request Request for new features or functionality on-testplan terminal General terminal issues that don't fall under another label
Milestone

Comments

@octref
Copy link
Contributor

octref commented Apr 23, 2018

Have an option to inherit previous session's directory, so when I'm splitting I always end up with two terminals of the same working directory. iTerm2 has this and is very useful:

image

@octref octref added feature-request Request for new features or functionality terminal General terminal issues that don't fall under another label labels Apr 23, 2018
@octref octref added this to the Backlog milestone Apr 23, 2018
@cedric05
Copy link
Contributor

cedric05 commented May 1, 2018

shall i work on it ?

@Tyriar
Copy link
Member

Tyriar commented May 1, 2018

@cedric05 I think this will need some ground work first to pull in the cwd in a nice way on all platforms which may be tricky.

@cedric05
Copy link
Contributor

cedric05 commented May 2, 2018

for windows there is no straight forward solution.
https://stackoverflow.com/a/25853120/5313475

@octref
Copy link
Contributor Author

octref commented Jun 24, 2018

I would find this really useful, as previously split terminal command splits at least for the same workspace. However that was gone in favor of split (in active workspace) two versions ago, which I don't find much useful.

Example: Let's say I have two workspace A/B.

  • Open new Terminal, select A
  • Split in A
  • Somehow the split panel is on B

@Tyriar Is that intended?

@Tyriar
Copy link
Member

Tyriar commented Jun 25, 2018

@octref the default split action now lets you select the workspace, just like the default create terminal action:

image

@octref
Copy link
Contributor Author

octref commented Jun 25, 2018

@Tyriar I'm more looking at the Split in active workspace one, because I don't want to do the selection when splitting each time. Currently the active workspace seems to be determined by the current open file. I would expect it to be determined by the terminal from which I'm splitting.

e.g.: If I have a terminal open on node-pty, splitting from it should always give me a terminal at the root of node-pty, no matter which file I'm on.

@Tyriar
Copy link
Member

Tyriar commented Jun 25, 2018

@octref yeah that's what this feature request is about, right?

@octref
Copy link
Contributor Author

octref commented Jun 25, 2018

@Tyriar Sorry, just found myself repeating myself unknowingly 😅

@Tyriar
Copy link
Member

Tyriar commented Oct 8, 2018

After chatting with @octref I found what would solve his problem is splitting taking the initialCwd of the terminal being split. This is so when in a multi-root workspace it won't show the popup. I propose we add a setting of the form:

terminal.integrated.splitCwd: 'choose' | 'initialCwd';

choose would be the current behavior, initialCwd would use the cwd of the terminal being split. Note that this is a string setting not a boolean to allow mac/linux to support the actual cwd in the future (doesn't appear to be possible without hacks on Windows). Also I didn't give the setting name/values much time, we can probably come up with better names.

@alexr00
Copy link
Member

alexr00 commented Oct 11, 2018

@Tyriar, just want to make sure I understand: initialCwd on Windows wouldn't do anything?

@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2018

@alexr00 initialCwd on Windows (and linux and mac) would use the initialCwd from the terminal being split:

https://github.com/Microsoft/vscode/blob/3ba326658d0dba29f238175fb79a6ddab08001af/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts#L36

@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2018

The follow up which we could do in October if you have time, would be to add a cwd option with the following behavior:

  • Linux/macOS: Run lsof -p <pid> | grep cwd when a split happens to pull the cwd
  • Windows: Fallback to initialCwd behavior (mention in setting doc)

@Tyriar Tyriar modified the milestones: Backlog, October 2018 Oct 15, 2018
alexr00 added a commit that referenced this issue Oct 17, 2018
Adds a new setting: `terminal.integrated.splitCwd`
With these options: `workspaceRoot`, `sourceInitialCwd`, `sourceCwd`
`workspaceRoot`is the existing behavior. The new split terminal's cwd will be the workspace root.
`sourceInitialCwd` uses the 'parent' terminals initial cwd for the new terminal.
`sourceCwd` on macOS and Linux this gets the cwd of the 'parent' terminal and uses that as the cwd for the new split terminal.
Default setting is to keep the existing behavior with `workspaceRoot`
Fixes #48447
@alexr00 alexr00 added the verification-needed Verification of issue is requested label Oct 29, 2018
@Tyriar Tyriar added on-testplan and removed verification-needed Verification of issue is requested labels Oct 29, 2018
@Tyriar
Copy link
Member

Tyriar commented Oct 29, 2018

@alexr00 I added a test plan item so we get better OS coverage for this one.

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality on-testplan terminal General terminal issues that don't fall under another label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants