mostafaqanbaryan / zellij-switch

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

Add optional third position for specifying layout. #4

Open theherk opened 1 week ago

theherk commented 1 week ago

Fixes #3

With this I can use 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::editor"
    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 launch with a project configuration.

Let me know what you think.

mostafaqanbaryan commented 3 days ago

Hi.

Thank you for this feature!

I'll check it out in a few days.