justfiles for automating various tasks on my workstation

Add utilities

Changed files
+67
+67
utilities.just
···
+
set unstable := true
+
set script-interpreter := ["uv", "run", "--script"]
+
# Quickly copy the Tailscale install command
[group('utilities')]
copy-ts-cmd:
···
echo "Unknown game"
;;
esac
+
+
# Create a .tar.gz archive from {{dir}}
+
[group('utilities')]
+
create-archive dir:
+
#!/usr/bin/env bash
+
set -eu
+
DIR_NAME={{ dir }}
+
archive_name="${DIR_NAME}-$(date '+%Y%m%d').tar.gz"
+
tar cvfz "$archive_name" "$DIR_NAME"
+
echo "Created archive $archive_name"
+
+
# Get the day of the week a given date falls on
+
[group('utilities')]
+
dayofweek year month day:
+
#!/usr/bin/python3
+
import sys
+
from datetime import datetime
+
+
if __name__ == "__main__":
+
if len(sys.argv) != 4:
+
print("Usage: dayofweek <year> <month> <day>")
+
exit(1)
+
else:
+
print(datetime(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])).strftime("%A"))
+
+
# Download an open source license
+
[group('utilities')]
+
get-license:
+
#!/usr/bin/env bash
+
set -euo pipefail
+
base_url="https://api.github.com/licenses"
+
headers="Accept: application/vnd.github.drax-preview+json"
+
res=$(curl --silent --header $headers $base_url)
+
selection=$(echo "$res" | jq ".[].key" | tr -d '"' | gum choose --limit=1)
+
res=$(curl --silent --header $headers $base_url/$selection | jq ."body")
+
echo -e "$res" | tr -d '"'
+
+
# Fetch and display public IP info
+
[group('utilities')]
+
[script]
+
myip:
+
# /// script
+
# dependencies = [
+
# "requests",
+
# ]
+
# ///
+
+
"""
+
myip - Fetch and display public IP information from ipinfo.io
+
"""
+
+
import json
+
import requests
+
+
if __name__ == "__main__":
+
KEY_COLOR = "\033[92m"
+
END_COLOR = "\033[0m"
+
+
response = requests.get("https://ipinfo.io", timeout=60)
+
json_data = json.loads(response.text)
+
+
print()
+
for item in json_data:
+
print(f"- {KEY_COLOR}{item.title():<16}{END_COLOR} {json_data[item]}")
# vim: ts=4 sts=4 sw=4 et ft=just