zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Prevent nesting?

Open LandonSchropp opened this issue 10 months ago • 7 comments

Is there a setting available to prevent nesting when attaching from inside of an existing Zellij session? For example, if I'm inside the remarkable-pancake, and I run zellij attach quirky-letters, is there a way I can automatically detach from remarkable-pancake before attaching to quirky-letters?

LandonSchropp avatar Aug 28 '23 18:08 LandonSchropp

I don't think there's a way to do this now from the CLI, but there is from plugins. We use it for the session-manager have you considered using it? (by default with Ctrl o + w starting from 0.38.0)

imsnif avatar Aug 28 '23 18:08 imsnif

@imsnif Thanks for the reply. I was mainly asking because I have a few scripts I was porting over from tmux that allow me to quickly spin up environments, so the session manager doesn't quite work with that.

LandonSchropp avatar Sep 22 '23 15:09 LandonSchropp

I would also like something like this. I use custom scripts to start sessions based on work directory.

It would be handy to have a zellij action detach instead of using shortcuts.

And a zellij switch <session_name> would also be great!

sommerper avatar Jan 29 '24 12:01 sommerper

@imsnif While the session-manager is nice I don't think it's very surprising that a lot of people have their own workflows, in some cases ported over from tmux. I assume most people using zellij are developers themselves and people like that will want to have their own workflows, often slapped together through scripts. Nothing wrong with that really.

Personally, I think the session-manager is a very slow way to achieve the same thing I can achieve using say skim or fzf, finding some project on disk and then switching to that. I can easily put together a script in 10 minutes or less that does this. If only I could switch sessions in zellij somehow through the cli from within zellij. But I can't. And instead I'm forced to either use the session-manager plugin which doesn't really work the way I want it to or not use zellij for this.

Well, in fact, I use zellij anyway because it's so good in so many ways. I just don't use sessions at all because they won't do what I want. I just use tabs for everything in a single session.

I would really like to use sessions though. What would be blocking implementing a cli for switching / attaching to sessions from within zellij without nesting?

johnae avatar Apr 20 '24 14:04 johnae

For reference, these other issues are related in some way: https://github.com/zellij-org/zellij/issues/3081 https://github.com/zellij-org/zellij/issues/2090

johnae avatar Apr 20 '24 14:04 johnae

Hi @johnae - here's my explanation why this will not be possible (likely ever) through the CLI in the issue you linked: https://github.com/zellij-org/zellij/issues/3081#issuecomment-1904349853

As I explained here, it's possible to do this through the plugin API, which is what the session-manager does. If you don't like the session-manager, you are more than welcome to fork it and make it behave exactly as you like. Bonus points: your new plugin will have 0 dependencies, you'll be able to port it to any machine with no installation - in fact, you'll even be able to load it directly from a URL.

I know many people got used to do it differently in other programs, that's okay. This is not how we do it here. I know programming in Rust or Go can be a barrier of entry to some, I'm working hard on adding SDKs in other languages to make this easier.

As for porting a workflow from other programs: I always warmly recommend not to do this. You will invariably reach situations like these. Approach Zellij with a clear mind, use it for its strengths. If you want to make it behave like another program, it might be better to stick with the other program. You'll be happier.

imsnif avatar Apr 22 '24 10:04 imsnif

@imsnif Fair enough. In fact, I've already started on a plugin in Rust. I guess I'll have to get with the program 😉.

johnae avatar Apr 22 '24 16:04 johnae