ckunte.net

# Bus times + routes

It’s been seven months since my daughter and I are taking the bus to commute. It’s always on time, well-equipped and environmentally friendlier — runs on natural gas; not electric yet. We use Transperth’s smart rider cards with discounted autoload feature enabled. It’s a fine experience.

While its site is great for planning trips, there are still a few inputs one needs to enter when looking-up routes and departure times. I wanted something simpler. So last night, I scraped bus times from their site for three stops — two near where I live and one from where I board for my return journey, and rolled them up into a csv file and a ripgrep shell script:

#!/usr/bin/env bash
# tp.sh -- Transperth bus timings from/to near my stop
# 2019 ckunte
if [ -z "$*" ]; then echo 'Include start hour or min. Examples:' echo 'sh tp.sh 16' echo 'sh tp.sh :2' exit 0 fi echo 'Transperth bus(es) starting at'$1':'
echo '  Time, Route'
rg \$1 ~/scripts/transperth.csv


It’s aliased in my .aliases file thus:

alias tp="bash ~/scripts/tp.sh"


So for example, when I call tp 07: at the command line, the script speed-searches through and lists all times in 0700 hour range — so I could decide when to leave.1

1. These are work week (Mon–Fri) schedules.