mostafaqanbaryan / zellij-switch

A Zellij plugin for in-session attach
17 stars 3 forks source link

Request layout argument #3

Closed theherk closed 2 days ago

theherk commented 2 weeks ago

Would be excellent to add the new --new-session-with-layout argument. I am starting with this script:

#!/usr/bin/env fish

function p # Get git project directory from .projects. See alias repocache.
    set REPO (zoxide query -l | rg --color=never -FxNf ~/.projects | sed s:"$HOME":~: | fzf --reverse)
    if test -n "$REPO"
        string replace '~' $HOME $REPO
    end
end

set -l pdir (p)
if test -z "$pdir"
    exit 1
end

set -l pname (basename $pdir)

if set -q ZELLIJ_SESSION_NAME
    if not string match -q "$pname" "$ZELLIJ_SESSION_NAME"
        zellij pipe --plugin file:~/bin/zellij-switch.wasm -- "$pname::$pdir"
    end
else
    cd $pdir
    if contains $pname (zellij list-sessions -ns)
        if contains $pname (zellij list-sessions -n | rg EXITED | cut -d' ' -f1 | cut -d':' -f2)
            zellij delete-session $pname
            zellij -n editor -s $pname
        else
            zellij attach $pname
        end
    else
        zellij -n editor -s $pname
    end
end

And I'd really love to do: zellij pipe --plugin file:~/bin/zellij-switch.wasm -- -n editor "$pname::$pdir"

theherk commented 2 weeks ago

I tried building with let layout_name = "editor"; on L21, but it didn't work as expected. I was hoping to add another optional suffix, so it could be invoked with "$name::$cwd::$layout".

I'll poke around at it some more. Let me know if you have some wisdom here.


To clarify, it still just launched with the default layout, rather than with layout editor.

mostafaqanbaryan commented 2 days ago

Resolved in https://github.com/mostafaqanbaryan/zellij-switch/pull/5 by @theherk.