#!/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 | # | | # | 02 Sep 2026: minor - help areas tweaked. No code changes. | # | 22 Jul 2026: Fixed special characters failing during upload | # | 21 Jun 2026: Help section edited for clarity | # | 16 Jun 2026: Initial Release | # '------------------------------------------------------------------------' # =========================================================================== # CONFIGURATION : START # =========================================================================== USERNAME="" # enter your username PASSWORD="" # fill in "your_password" or leave blank to be prompted EDITOR="tilde" # enter terminal text editor name URL="https://plan.cat" # The server name. Do not modify. # =========================================================================== # CONFIGURATION : END # =========================================================================== show_help() { cat << 'EOF' .------------------------------------------------------------------. | plancat: Update your plan.cat plan file 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: Enter password or leave BLANK to be prompted | | - 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=<${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}"