resurrect.wezterm icon indicating copy to clipboard operation
resurrect.wezterm copied to clipboard

How to connect to a domain when restoring session.

Open Tanish2002 opened this issue 11 months ago • 4 comments

Like we can restore the session/workspace inside the current window. I would like to also attach to a domain when restoring a session.

I'm using smart_workspace_switcher, and when I select a workspace I would like to attach to the unix domain which I've specified in my config and then restore my workspace all in the same window without any new windows spawning.

Is this possible?

Tanish2002 avatar Dec 31 '24 16:12 Tanish2002

I wanted to explain this more clearly.

By default, when I open WezTerm, it attaches to the "local" domain. This domain is temporary and gets destroyed once I close the window.

On the other hand, Unix domains in WezTerm behave differently—they don't automatically detach. Instead, they detach only on exit.

Here's the functionality I’d like to achieve:

  • When I open WezTerm normally, it should attach to the "local" domain as usual, and the domain should be destroyed on exit.
  • However, when I use the smart_workspace_switcher to open a workspace, it should operate within a Unix domain.
    • If the workspace already exists, it should simply switch to that (nothing to resurrect).
    • If the workspace doesn’t exist, it should create the workspace in the Unix domain and resurrect it using resurrect.wezterm.

This workflow is similar to what I used to have with the t-smart-tmux-session-manager. I’m hoping to replicate this behavior with resurrect.wezterm and smart_workspace_switcher.

Tanish2002 avatar Jan 01 '25 12:01 Tanish2002

Some parts of this seem to already be possible, however there seems to be some limitations

I can open a Unix domain with: wezterm connect unix and use smart_workspace_switcher to change and resurrect the workspace. I can also open another Unix domain with wezterm connect unix and connect to the same workspace, or create another one.

However there seems to be a problem with workspaces with multiple windows, as it spawns 2 windows sharing the same pane. If you are only ever using one window, then this might not be a problem for you.

Here are my dotfiles, if you want to replicate it.

Does this help?

MLFlexer avatar Jan 03 '25 19:01 MLFlexer

Thanks for the suggestion! I tried it, and it works fine.

I can configure WezTerm to always open with wezterm connect unix. However, the issue is that I want the "default" workspace to be exempted from the domain.

To clarify, when I used t-smart-tmux-session-manager, opening a terminal by default gave me a plain terminal window—no tmux or sessions attached. This was convenient for quickly opening terminal windows to work without any additional setup. When I needed tmux, I could simply run the script to attach to a session.

With WezTerm, if I open it using wezterm connect unix, it always attaches to the default workspace in the unix domain. This means that every time I open a new terminal window, instead of getting a plain terminal I get the same detached default workspace attached again, which is not what I want.

So, while your approach works for other workspaces (since I typically only have one window per workspace), the "default" workspace behavior creates a problem for me.

Specifically, this part you mentioned:

However, there seems to be a problem with workspaces with multiple windows, as it spawns 2 windows sharing the same pane. If you are only ever using one window, then this might not be a problem for you.

This would indeed be an issue for me, but only for the default workspace. For other workspaces, I always use a single window.

I hope this provides clarity on my use case! Let me know if there are any ideas or workarounds for this. Thanks again!

Tanish2002 avatar Jan 03 '25 20:01 Tanish2002

The only idea that I have is to modify the default_workspace config option by changing the option by maybe appending a timestamp to it? I don't know if this would work though...

You can also try to hear the people on [Matrix]https://app.element.io/#/room/#wezterm:matrix.org) sometimes there are great ideas on there 😄

MLFlexer avatar Jan 23 '25 09:01 MLFlexer