zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
20.95k stars 639 forks source link

IDEA: Install instead of launch (official launch script modified) #3473

Open agarzon opened 3 months ago

agarzon commented 3 months ago

Hi, I just met zellij and love this script, I used to use byobu but this one is cooler

Anyways, I made a modification from the original launch script that instead of just running it, it actually installs in your machine. bash <(curl -L zellij.dev/launch)

You can change the install_dir to whatever path you want, In my case I want it to be in /usr/local/bin

#!/usr/bin/env bash

install_dir="/usr/local/bin"
tmp_dir="/tmp/zellij/bootstrap"
mkdir -p "$tmp_dir"

if [[ -x "$install_dir/zellij" ]]
then
    "$install_dir/zellij" "$@"
    exit
fi

case $(uname -m) in
    "x86_64"|"aarch64")
        arch=$(uname -m)
    ;;
    "arm64")
        arch="aarch64"
    ;;
    *)
        echo "Unsupported cpu arch: $(uname -m)"
        exit 2
    ;;
esac

case $(uname -s) in
    "Linux")
        sys="unknown-linux-musl"
    ;;
    "Darwin")
        sys="apple-darwin"
    ;;
    *)
        echo "Unsupported system: $(uname -s)"
        exit 2
    ;;
esac

url="https://github.com/zellij-org/zellij/releases/latest/download/zellij-$arch-$sys.tar.gz"
curl --location "$url" | tar -C "$tmp_dir" -xz
if [[ $? -ne 0 ]]
then
    echo
    echo "Extracting binary failed, cannot launch zellij :("
    echo "One probable cause is that a new release just happened and the binary is currently building."
    echo "Maybe try again later? :)"
    exit 1
fi

if mv "$tmp_dir/zellij" "$install_dir/"
then
    chmod +x "$install_dir/zellij"
    echo "zellij installed successfully to $install_dir"
else
    echo "Failed to move zellij to $install_dir"
    exit 1
fi

"$install_dir/zellij" "$@"
exit

I made this because there are not debian/ubutu release yet.