Skip to content

Instantly share code, notes, and snippets.

@rhaberkorn
Created May 16, 2025 21:46
Show Gist options
  • Save rhaberkorn/8bca1ab604a8588be2800604efe88182 to your computer and use it in GitHub Desktop.
Save rhaberkorn/8bca1ab604a8588be2800604efe88182 to your computer and use it in GitHub Desktop.
Minimalist Timebutler CLI interface
#!env bash
# ./timebutler start|pause|resume|stop|cancel|status [project]
# You have to set USERID and AUTH variables in ~/.timebutler!
# Run `curl -X POST 'https://timebutler.de/api/v1/users' -d "auth=$AUTH"` to fetch user ids.
set -e
. ~/.timebutler
test -n "$AUTH" -a -n "$USERID"
COMMAND=$1
if [ -z "$COMMAND" ]; then
echo "Missing command"
exit 1
fi
PROJECT=$2
if [ -n "$PROJECT" ]; then
PROJECTID=(`curl -s -X POST 'https://timebutler.de/api/v1/projects' -d "auth=$AUTH" | awk -F ';' "\\$2~/$PROJECT/ {print \\$1}"`)
if [ ${#PROJECTID[*]} != 1 ]; then
echo "Unknown or ambiguous project \"$PROJECT\""
exit 1
fi
ARGS="$ARGS -d projectid=$PROJECTID"
fi
exec curl -X POST 'https://timebutler.de/api/v1/timeclock' -d "auth=$AUTH" -d "userid=$USERID" -d "command=$COMMAND" $ARGS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment