#!/usr/bin/env bash # .------------------------------------------------------------------------. # | plancat: Uses plan.cat's API to automate posting to your account | # | | # | License: Blue Oak Model License 1.0.0 | # | https://blueoakcouncil.org/license/1.0.0 | # | | # | Copyright: https://640kb.neocities.org | # | | # | 16 Jun 2026: Initial Release | # '------------------------------------------------------------------------' # --- CONFIGURATION (Edit these values) ------------------------------------- USERNAME="" # enter your username URL="https://plan.cat" EDITOR="tilde" # enter terminal text editor name PASSWORD="" # Leave blank to be prompted or fill in "your_password" # --- END CONFIGURATION ----------------------------------------------------- show_help() { cat << 'EOF' .------------------------------------------------------------------. | plancat: Automate your updates to plan.cat via the command line. | | | | Retrieves your current .plan, loads it into your editor and | | uploads the changes to plan.cat when the editor closes. | | | | Usage: plancat - Edit and post your .plan | | plancat [-h | --help] - Shows this help message | | | | Configuration: | | 1. Open this script in your editor manually. | | | | 2. Update the "CONFIGURATION" section at the top: | | - USERNAME: Your plan.cat username | | - PASSWORD: Leave BLANK to be prompted or enter password | | - EDITOR : Your preferred terminal editor | | | | Security Notes: | | If PASSWORD is blank, you will be prompted to type it. | | (read -s: hidden input, not saved to history) | | If filled, it is stored in plain text in this script. | | | | Requirements: | | curl, mktemp and a terminal text editor | | Compatibility: Linux, macOS, *BSD | '------------------------------------------------------------------' EOF } case "${1:-}" in -h|--help) show_help exit 0 ;; "") ;; *) echo "Unknown option: $1" echo "Use '-h' or '--help' for usage information." exit 1 ;; esac set -euo pipefail if ! command -v "$EDITOR" &>/dev/null; then echo "Error: Editor '$EDITOR' not found in your PATH." echo "Please update the 'EDITOR' variable inside this script." exit 1 fi if [[ -z "$PASSWORD" ]]; then echo "Password not set. Please enter your plan.cat password:" read -s PASSWORD echo "" if [[ -z "$PASSWORD" ]]; then echo "Error: Password cannot be empty." exit 1 fi fi TMP_FILE=$(mktemp) echo "Fetching current .plan..." if ! curl -s -o "$TMP_FILE" "${URL}/~${USERNAME}"; then echo "Error: Failed to fetch current .plan file." rm -f "$TMP_FILE" exit 1 fi echo "Editing with $EDITOR..." "$EDITOR" "$TMP_FILE" echo "Uploading..." if ! curl -s -X POST -u "${USERNAME}:${PASSWORD}" \ -F "plan=$(cat "$TMP_FILE")" \ "${URL}/stdin"; then echo "Error: Upload failed. Check your username and password." rm -f "$TMP_FILE" exit 1 fi rm -f "$TMP_FILE" echo "Success! Your .plan has been updated at: ${URL}/~${USERNAME}"