Hi r/cpp 👋 long-time lurker, first-time poster :)
Quick story: I once lived in NYC, I work in Terminal, and the workflow of "leave desk → walk to station → realize I don't know when the next train is → unlock phone → wait for MTA app → squint → miss train" got old around year two. So I wrote a thing.
So I wrote
mta, a single C++ binary that hits the MTA's GTFS-realtime feeds and prints next-train times the way the actual station signs render them: official line bullets, color-coded ETAs (bold red = now, green = catchable, yellow = soon, dim = far), grouped by direction so a busy hub like Times Square fits on one screen.How to Install:
brew tap itsashishupadhyay/mta
brew install mta
mta -s "Times Sq"brew tap itsashishupadhyay/mta
brew install mta
mta -s "Times Sq"
Some Commands to try:
mta -s "Times Sq" # next trains at every line, both directions
mta -s "bedfrod avr" # fuzzy match, misspell, similar stations
mta -s "bay prkwy" # 3 stations called Bay Pkwy. picker tells you which is which
mta -s "Penn Station" -d "DeKalb Av" # end-to-end route plan with transfers
mta -s "Times Sq" -d "Bedford Av" -v # same but verbose. per-stop diagram, the prettiest output
mta -s "Bay Ridge-95" -d "Forest Hills" -t 10 # only show trains leaving 10+ min from now
mta -s "14 St-Union Sq" -l L # filter to one line. less scrolling
mta --help # everything else
A few things I'm weirdly proud of:
\- No API key MTA dropped the auth requirement in 2020, and apparently nobody told anyone.
\- No daemon, no TUI loop It prints and exits, so it composes with tmux panes, shell pipes, Hammerspoon menubar scripts, whatever.
\- Connected-complex resolution Searching `Times Sq` automatically pulls in the A/C/E platforms over at 42 St-Port Authority and labels them so you know where to walk.
\- Routing too `mta -s "Times Sq" -d "Bedford Av"` runs Dijkstra over the live transfer graph and gives you 5 ranked options.
It's MIT, written in C++17, builds in \~30 seconds from source (on my Mac M3) if you don't want to `brew` it, or cross compile
Repo + screenshots: https://github.com/itsashishupadhyay/NYC\_MTA\_Timetable
I would appreciate feedback, especially on the rendering at narrow terminal widths, and from anyone who knows GTFS-realtime well enough to tell me what I got wrong. Critique welcome; this is my first real OSS release, and I'd rather hear it now.
If you're in NYC: Please try it on your home/work/regular station, and please reply with what's wrong, missing, or weird.
https://redd.it/1t9sq14
@r_cpp