--- /dev/null
+#!/bin/bash
+
+# send a toot
+
+# If any arguments are provided, they form the toot, otherwise stdin is used.
+# If $1 is one of "PUBLIC", "UNLISTED", "PRIVATE", or "DIRECT" (case-sensitive),
+# then the post visibility is set to that, otherwise $1 stays part of the
+# resulting toot.
+
+# config file
+config="${XDG_CONFIG_HOME:-$HOME/.config}/tootsh-toot"
+
+# source the "config file"
+# this needs to set $token and $instance
+[[ -e "$config" ]] || {
+ echo "Missing config file at $config"
+ exit 1
+}
+. "$config"
+
+# verify config
+[[ "$token" == "" ]] && {
+ echo '$token'" needs to be set in config file at $config"
+ exit 1
+}
+[[ "$instance" == "" ]] && {
+ echo '$instance'" needs to be set in config file at $config"
+ exit 1
+}
+
+# post visibility
+visibility="public"
+if [[ "$1" == "PUBLIC" ]] ; then
+ shift
+elif [[ "$1" == "UNLISTED" ]] ; then
+ visibility="unlisted"
+ shift
+elif [[ "$1" == "PRIVATE" ]] ; then
+ visibility="private"
+ shift
+elif [[ "$1" == "DIRECT" ]] ; then
+ visibility="direct"
+ shift
+fi
+
+# get toot content
+toot="$@"
+if [[ "$toot" == "" ]] ; then
+ while read l ; do
+ [[ "$l" == "." ]] && break || toot+="$l\\n"
+ done
+fi
+
+echo -n "tooting... "
+
+itoken="$(echo "$toot" | base64)"
+
+curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" \
+ -H "Idempotency-Key: $itoken" \
+ -d "{\"status\":\"$toot\",\"visibility\":\"$visibility\"}" \
+ "https://$instance/api/v1/statuses" 2>/dev/null | jq '.url'