View Upcoming Google Calendar Events via the Terminal

Terris Linenbach

--

Keep it simple and don’t miss anything important!

Nerd Mode

Here’s how to list upcoming Google Calendar events in your terminal:

  1. Install Python
  2. Install gcalcli via “pip install gcalcli” or consult the README
  3. Run “gcalcli” and set up your access token
  4. Run the following script. The list of events will update itself every five minutes.
#!/bin/bash

# 1. Install Python
# 2. pip install gcalcli
# 3. get an access token

# Exit on any error
set -e

# Handle SIGINT (Ctrl+C) and SIGTERM
cleanup() {
echo
echo "Calendar check script terminated."
exit 0
}

trap cleanup SIGINT SIGTERM

# Check if gcalcli is installed
if ! command -v gcalcli &> /dev/null; then
echo "Error: gcalcli is not installed. Please install it first."
echo "You can install it using: pip install gcalcli"
exit 1
fi

echo "Starting calendar check script (checking every 5 minutes)"
echo "Press Ctrl+C to exit"
echo

while true; do
clear
echo "=== Calendar Check: $(date) ==="
echo "Fetching upcoming events..."
echo

if ! gcalcli agenda --nostarted --nodeclined; then
echo "Error: Failed to fetch calendar events"
sleep 300 # Still wait 5 minutes before retrying
continue
fi

echo
sleep 300 # Wait for 5 minutes
done

--

--

No responses yet