wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.55k stars 785 forks source link

Ability to force default_cwd on new pane/tab/window #5038

Open LunarLambda opened 8 months ago

LunarLambda commented 8 months ago

Is your feature request related to a problem? Please describe. According to default_cwd there's no (straightforward, non-programmatic) way to opt out of the behaviour that any new terminals will try to use OSC 7/the current process leader's cwd. 9 out of 10 times I do not want that and immediately cd to my home dir since I use tabs for completely unrelated contexts and tasks and otherwise rely on shell jobs and my editor for multitasking within the same context.

Describe the solution you'd like A simple boolean or string option to override the default_cwd behaviour for new panes/tabs to opt out of the OSC 7/process leader querying behaviour. I would like all new terminals to default to my home directory unless explicitly opened with --cwd.

Describe alternatives you've considered It's probably possible to override the default keybindings to always pass --cwd wezterm.home_dir but it's not immediately obvious how to do so, and I'm trying to keep my configuration as minimal and declarative as possible since the default keybindings are fine for me.

twpayne commented 2 weeks ago

I would also very much like this functionality: it's frustrating when I have to type cd to switch to my home directory every time I open a new window.

Would you accept a PR that implements this? I would propose to add two new configuration variables:

Variable Effect
new_window_cwd Initial working directory for new windows, if unset keeps the existing behavior.
new_tab_cwd Initial working directory for new tab, if unset keeps the existing behavior.

How does this sound?