Automatic naming of Zellij tabs

Zellij is a terminal multiplexer, similar to screen, except I manage to understand and remember the shortcuts for this one. The configuration is far too complex, and so I'm mainly using the defaults for it, except that I use default_layout "compact" to save some screen space.

I tend to work with too many tabs at the same time, and having them named "Tab #1", "Tab #2' doesn't really help me. Instead, here is a small script that integrates with fish to update the name based on the folder you're in. (taken from this reddit post)

function zellij_tab_name_update --on-variable PWD
    if set -q ZELLIJ
        set tab_name ''
        if git rev-parse --is-inside-work-tree >/dev/null 2>&1
            set git_root (basename (git rev-parse --show-toplevel))
            set git_prefix (git rev-parse --show-prefix)
            set tab_name "$git_root/$git_prefix"
            set tab_name (string trim -c / "$tab_name") # Remove trailing slash
        else
            set tab_name $PWD
            if test "$tab_name" = "$HOME"
                set tab_name "~"
            else
                set tab_name (basename "$tab_name")
            end
        end
        command nohup zellij action rename-tab $tab_name >/dev/null 2>&1 &
    end
end

Published on 2026-05-07 #zellij , #terminal - In code