Skip to content

Instantly share code, notes, and snippets.

@clbarnes
Created March 10, 2024 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clbarnes/f1e22b2a51fd8f7be10a69d073687d55 to your computer and use it in GitHub Desktop.
Save clbarnes/f1e22b2a51fd8f7be10a69d073687d55 to your computer and use it in GitHub Desktop.
Wrapper script for zellij
#!/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"
fi
echo $timestamp > $timepath
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