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

zellij with --layout and --session no longer works #3734

Open
theherk opened this issue Nov 6, 2024 · 4 comments
Open

zellij with --layout and --session no longer works #3734

theherk opened this issue Nov 6, 2024 · 4 comments

Comments

@theherk
Copy link

theherk commented Nov 6, 2024

Issue description

I generally use this script to start or connect to sessions:

#!/usr/bin/env fish

if set -q ZELLIJ_SESSION_NAME
    echo "Already in zellij session."
else
    set -l p (basename (git root))
    if contains $p (zellij list-sessions -ns)
        if contains $p (zellij list-sessions -n | rg EXITED | cut -d' ' -f1 | cut -d':' -f2)
            zellij delete-session $p
            zellij -l editor -s $p
        else
            zellij attach $p
        end
    else
        zellij -l editor -s $p # no longer works
        # zellij -n editor -s $p # works now
    end
end

Since upgrading to 0.41.1 I can no longer start new sessions this way. That is just what tipped me off, but the behavior can been seen more simply.

Minimal reproduction

  1. Have zero configuration aside from a layout test.kdl that can be empty.
  2. Run zellij -l test -s test.

That's it. This now gives There is no active session!. You might say to use zellij --new-session-with-layout test -s test, and that does work. However, that behavior is a bit confusing. The documentation for --session says

-s, --session <SESSION>
       Specify name of a new session

Seems to me There is no active session! shouldn't be possible when using this option. Of course there isn't one; I asked to start one.

I'm of course fine with using -n in lieu of -s, but I'm a bit confused.

@imsnif
Copy link
Member

imsnif commented Nov 6, 2024

Hey, this is mentioned in the breaking changes part of the release notes. --layout now works differently in and out of sessions. It either works on the current session if in one or starts a new session with this layout if not. --session is there to tell it to work on a different existing session instead of the current one. I agree the word "new" should probably be dropped from the --help of session.

The old behavior can be achieved, as you have found (but I'm writing here for others who might find this issue) with --new-session-with-layout.

@brandondrew
Copy link

if the help text contradicts the behavior, that's definitely a bug, even if the fix is to change the help text

@brandondrew
Copy link

Here's the change log for anyone looking... to save them a few seconds 😅
https://github.com/zellij-org/zellij/releases#release-v0.41.0

The changes look absolutely EPIC! 🎉

@artfulrobot
Copy link

Thanks for your work and releasing a new version.

I hit this too. I had read this:

The --layout flag is not idempotent(-ish): This flag, used to start a new Zellij session with the specified layout, now behaves differently if run inside a Zellij session. In this case, it will load the layout as one or more additional tabs into the session. This should make this flag an easy default choice for loading layouts: it will probably do what you want wherever you run it, rather than creating a nested Zellij session. For the old behavior, use the new --new-session-with-layout flag.

But "now behaves differently if run inside a Zellij session" - well I didn't care about that because I'm trying to start a session, so there is no session. The error/docs/release notes are confusing my small brain.

FYI here's how I start zellij: basically, attach to a session called 'main', creating it if it doesn't exist. This is the new version with the new argument in place of --layout

function z
  if zellij ls -n &| grep -E '^main .*EXITED' >/dev/null
    zellij delete-session main # delete dead session
  end
  if zellij ls -n &| grep -E '^main ' >/dev/null
    zellij attach main
  else
    # We don't have a main session yet
    zellij --session main --new-session-with-layout mine
  end
end

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

No branches or pull requests

4 participants