Overview
trop assigns port numbers to directories. It is useful when you run development servers in several worktrees and want each one to keep its own port.
PORT=$(trop reserve) && npm run dev -- --port "$PORT"This example assumes an npm dev script that accepts --port. trop reserve prints the port to stdout; diagnostics go to stderr. The && starts the server only if the reservation succeeds.
A reservation is a record in a local SQLite database, keyed by a directory and an optional tag:
- Repeating
trop reservein the same directory returns the stored port. - A different directory or tag gets a separate reservation.
- Reservations persist when a server stops. Release or prune them when you no longer need them.
Any directory works; it does not have to be a Git worktree. Concurrent callers coordinate through the same database, stored in ~/.trop by default.
The record does not hold a socket open or prevent another program from taking the port. See Scope for the limits, or Usage for installation and commands.