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

How to connect to a domain when restoring session. #84

Open
Tanish2002 opened this issue Dec 31, 2024 · 4 comments
Open

How to connect to a domain when restoring session. #84

Tanish2002 opened this issue Dec 31, 2024 · 4 comments
Labels
question Further information is requested

Comments

@Tanish2002
Copy link

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
Copy link
Author

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.

@MLFlexer
Copy link
Owner

MLFlexer commented Jan 3, 2025

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 MLFlexer added the question Further information is requested label Jan 3, 2025
@Tanish2002
Copy link
Author

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!

@MLFlexer
Copy link
Owner

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants