Last active
January 30, 2025 14:14
-
-
Save clbarnes/f1e22b2a51fd8f7be10a69d073687d55 to your computer and use it in GitHub Desktop.
Wrapper script for zellij
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/bash | |
# Script which uses the cached zellij if it exists; | |
# otherwise downloads a fresh copy. | |
# Deletes the cached copy every month. | |
set -euo pipefail | |
launchpath="/tmp/zellij/launch" | |
timepath="/tmp/zellij/last_updated" | |
timestamp=$(date +%s) | |
timeout=$((60*60*24*28)) | |
if [[ -f "$timestamp" ]] | |
then | |
oldts=$(cat "$timestamp") | |
if [ $(( $oldts + $timeout )) -le $timestamp ] | |
then | |
rm -rf /tmp/zellij | |
fi | |
fi | |
mkdir -p /tmp/zellij | |
if [[ -x "$launchpath" ]] | |
then | |
else | |
curl -L zellij.dev/launch -o "$launchpath" | |
echo $timestamp > $timepath | |
fi | |
if [ "$#" -eq 0 ] | |
then | |
exec /bin/bash "$launchpath" attach --create | |
else | |
exec /bin/bash "$launchpath" "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment