main
1#!/usr/bin/env bash
2# Generate UUIDs, timestamps, and other IDs for raffi script filter.
3# Outputs Alfred Script Filter JSON format.
4set -euo pipefail
5
6uuid=$(cat /proc/sys/kernel/random/uuid)
7uuid_short=$(echo "$uuid" | tr -d '-')
8ts_epoch=$(date +%s)
9ts_iso=$(date -u +%Y-%m-%dT%H:%M:%SZ)
10ts_date=$(date +%Y-%m-%d)
11ts_datetime=$(date "+%Y-%m-%d %H:%M:%S")
12
13jq -n --arg uuid "$uuid" \
14 --arg uuid_short "$uuid_short" \
15 --arg ts_epoch "$ts_epoch" \
16 --arg ts_iso "$ts_iso" \
17 --arg ts_date "$ts_date" \
18 --arg ts_datetime "$ts_datetime" \
19'{
20 "items": [
21 {"title": "UUID", "subtitle": $uuid, "arg": $uuid},
22 {"title": "UUID (no dashes)", "subtitle": $uuid_short, "arg": $uuid_short},
23 {"title": "Epoch", "subtitle": $ts_epoch, "arg": $ts_epoch},
24 {"title": "ISO 8601", "subtitle": $ts_iso, "arg": $ts_iso},
25 {"title": "Date", "subtitle": $ts_date, "arg": $ts_date},
26 {"title": "Date Time", "subtitle": $ts_datetime, "arg": $ts_datetime}
27 ]
28}'