Search code examples
bashalacritty

How can I start Zellij only with Alacritty?


I've recently hear about Zellij and Alacritty.

I'm using bash. According to Zellij's documentation, I can automatically start it and add completions by adding the following to my .bashrc:

# Autostart
eval "$(zellij setup --generate-auto-start bash)"
# Add completions
eval "$(zellij setup --generate-completion bash)"

This works but, as expected, this creates a new Zellij session whenever I start bash, even through VSCode.

enter image description here

The thing is, because VSCode space is limited, I won't necessarily want to run Zellij on it. Is it possible to run the commands for auto start and completion only in Alacritty?

I tried moving the two Zellij lines to a separate script and create the Alacritty configuration file below, but it didn't work:

[shell]
program = "/bin/bash"
args = ["-c", ".", "/path/to/my/alacritty-start.sh", "&&", "bash" ]

Solution

  • You could check if the value of $TERM is set accordingly, e.g. to alacritty, , and only then start Zellij. For example (in your .bashrc):

    [ "$TERM" != alacritty ] || eval "$(zellij setup --generate-auto-start bash)"
    

    Alternatively, alacritty registers some other environment variables (like ALACRITTY_LOG, ALACRITTY_SOCKET, ALACRITTY_WINDOW_ID), you could also check for:

    [ -z "$ALACRITTY_LOG" ] || eval "$(zellij setup --generate-auto-start bash)"