Created
August 26, 2023 17:08
-
-
Save t0xicCode/bad70e302db1964dee8ab6bb4171cb54 to your computer and use it in GitHub Desktop.
Zellij Install Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright (c) 2023 MagnaX Software | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
set -eu | |
version="latest" | |
target="" | |
arch="" | |
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in | |
linux) | |
target="unknown-linux-musl" | |
;; | |
*) | |
echo "Unknown kernel: $(uname -s)" >&2 | |
exit 1 | |
;; | |
esac | |
case "$(uname -m | tr '[:upper:]' '[:lower:]')" in | |
x86_64) | |
arch=x86_64 | |
;; | |
aarch64) | |
arch=aarch64 | |
;; | |
*) | |
echo "Unknown architecture: $(uname -m)" >&2 | |
exit 1 | |
;; | |
esac | |
filename="zellij-${arch}-${target}.tar.gz" | |
download_url="https://github.com/zellij-org/zellij/releases/${version}/download/${filename}" | |
exec 3>&1 | |
log() { | |
echo "$(date "+%Y.%m.%d-%H:%M:%S"): $@" >&3 | |
} | |
download_tarball() { | |
log "Downloading zellij ${version}" | |
if [ `which curl` ]; then | |
curl -sS -L "${download_url}" -o "${tmp}/${filename}" | |
elif [ `which wget` ]; then | |
wget -nv "${download_url}" -O "${tmp}/${filename}" | |
else | |
log "Neither curl nor wget are available" | |
exit 1 | |
fi | |
} | |
extract_install_tarball() { | |
log "Extracting..." | |
tar xzf "${tmp}/${filename}" -C /usr/local/bin --unlink-first zellij | |
chmod +x /usr/local/bin/zellij | |
} | |
tmp=`mktemp -d` | |
download_tarball | |
extract_install_tarball | |
if [ -n "${ZELLIJ_INSTALL_AUTO+1}" ]; then | |
log "Adding autostart to .bashrc" | |
cat >> ~/.bashrc <<'EOF' | |
# zellij section | |
eval "$(zellij setup --generate-completion bash)" | |
export ZELLIJ_AUTO_ATTACH=true | |
export ZELLIJ_AUTO_EXIT=true | |
eval "$(zellij setup --generate-auto-start bash)" | |
EOF | |
fi | |
rm -rf "${tmp}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment