Skip to content

cyrilghali/metro-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


🚇 metro-cli

C'est dans combien le prochain ?

Real-time Ile-de-France departures and disruptions in your terminal.


CI Release License Go


$ metro departures chatelet

  Châtelet (Paris)

  Line   Direction                  Next departures
  ----   ---------                  ---------------
  M1     La Défense                 2 min, 5 min, 9 min
  M1     Château de Vincennes       now, 4 min, 8 min
  M4     Porte de Clignancourt      3 min, 7 min
  M14    Olympiades                 2 min, 5 min

$ metro departures chatelet --mode rer

  Châtelet les Halles (Paris)

  Line    Direction                  Next departures
  ----    ---------                  ---------------
  RER A   Marne-la-Vallée Chessy     2 min, 14 min
  RER B   Aéroport CDG 2 TGV        4 min, 19 min
  RER D   Creil                      7 min

$ metro disruptions --mode rer

  Line    Status       Info
  ----    ------       ----
  RER A   OK
  RER B   OK
  RER C   Modified     Issy : gare non desservie
  RER D   Delays       Plan de transport adapté
  RER E   OK


Install

Quick install (Linux / macOS):

curl -sSfL https://raw.githubusercontent.com/cyrilghali/metro-cli/master/install.sh | sh

This downloads the latest release binary and installs it to /usr/local/bin (may prompt for sudo). Run it again at any time to update to the latest version.

From source:

go install github.com/cyrilghali/metro-cli/cmd/metro@latest

Or clone and build:

git clone https://github.com/cyrilghali/metro-cli.git
cd metro-cli
go build -o metro ./cmd/metro

Setup

Get a free API token at prim.iledefrance-mobilites.fr, then:

export PRIM_TOKEN=your_token

Add it to your shell profile (~/.bashrc, ~/.zshrc, etc.) to make it permanent.

Save a default place so you can just run metro d:

metro places save home chatelet
metro places default home

Usage

metro departures — next trains

metro departures chatelet              # search by station name (all modes)
metro d chatelet                       # short alias
metro dep "gare de lyon"              # quotes for multi-word names
metro d "73 rue rivoli"                # search by address (finds nearby stops)
metro d home                           # use a saved place (see "metro places")
metro d --here                         # auto-detect location via browser
metro d                                # uses your default place
metro d chatelet -m metro              # metro only
metro d chatelet -m rer                # RER only

When multiple stations match, an interactive picker lets you choose, then offers to save it for instant access next time:

Multiple results found:
  1. Châtelet (Stop [M1, M4, M7, M11, M14]) - Paris
  2. Châtelet les Halles (Stop [RER A, RER B, RER D]) - Paris
  3. Château d'Eau (Stop [M4]) - Paris

Pick a number: 1

Save for next time? (name or Enter to skip): home
Saved! Next time just run: metro d home

metro disruptions — line status

metro disruptions                      # all lines (default)
metro dis                              # short alias
metro status                           # another alias
metro dis -m metro                     # metro lines only
metro dis -m rer                       # RER lines only
metro dis --line A                     # filter by line

Status is color-coded in your terminal:

Color Meaning
🟢 Green Normal service
🟡 Yellow Delays / reduced / modified service
🔴 Red Service interrupted

--mode — transport modes

Both departures and disruptions accept a --mode / -m flag:

Mode What Lines
all Everything (default) All modes
metro Metro M1-M14, M3B, M7B
rer RER A, B, C, D, E
train Transilien H, J, K, L, N, P, R, U
tram Tramway T1-T13
bus Bus All IDF bus lines

metro places — saved places

Save stations you use often and skip the search + picker entirely:

metro places                           # list saved places
metro places save home chatelet        # save "chatelet" as "home"
metro places save work "la defense"    # save "la defense" as "work"
metro places default home               # set default for "metro d"
metro places remove home               # remove a saved place

Then just use the alias:

metro d home                           # instant — no search, no picker
metro d work -m rer                    # works with all flags
metro d                                # uses the default place

metro config — settings

metro config                           # view current config

Saved places and default are stored in ~/.metro.toml. The API token is read from the PRIM_TOKEN environment variable.


The --here flag

The --here flag finds stops near your current location:

  1. Starts a temporary local HTTP server
  2. Opens your browser
  3. Browser asks for geolocation permission
  4. Coordinates are sent back to the CLI
  5. Nearby stops are found within 500m

Works on macOS, Linux, and Windows.


How it works

Feature How
Saved places Aliases stored in ~/.metro.toml, bypass API search
Station search PRIM places API with mode filtering + interactive picker
Address search Navitia geocoding → nearby stops within 500m
Geolocation Temporary localhost server + browser navigator.geolocation
Departures Navitia v2 real-time API, filtered by transport mode
Disruptions Navitia lines endpoint with embedded disruption data

All data comes from the PRIM Ile-de-France Mobilites API gateway.


License

MIT

About

Paris metro departures and disruptions CLI

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors