u/JohnHopeman

▲ 10 r/tui+1 crossposts

Lsport - Command-line utility for inspecting and managing TCP ports

Hey everyone,

I just published my first open source project on PyPI and would love some honest feedback before I keep iterating.

The problem

Two pain points I kept hitting:

  1. No clean way to see what's running where. lsof -i -P -n | grep LISTEN works, but the output is noisy and columnar — you have to mentally filter it every time. There's no single command that just tells you "here are the ports currently in use, by which process."
  2. Killing a port-holder is a multi-step dance:

lsof -i :3000 to find the PID, then kill -9 <PID> and hope it's the right one. Two commands, copy-paste a PID, parse columns. Across a workday it adds up.

What lsport does

pipx install lsport

Three subcommands:

  • lsport list — all TCP ports currently in use, rendered as a clean table (PID, port, process, user). One command, one glance.
  • lsport kill 3000 — kills whatever owns that port, with a confirmation prompt.
  • lsport interactive — a TUI to browse and kill from a table view.

Works on macOS and Linux. Windows isn't supported yet — I don't have a reliable way to test it.

Tech

Python 3.9+, single-module. psutil for cross-platform socket/process enumeration, rich for table rendering and the TUI, tests with pytest, lint/format with ruff. Published via PyPI Trusted Publishing (OIDC) — no API tokens stored anywhere.

Why not just fuser -k 3000/tcp or a shell alias?

Fair question. fuser is Linux-only and the UX is rough. lsof | grep | awk | xargs kill works but is fragile, and it still doesn't solve the "show me everything at a glance" case. I wanted something opinionated that handles the 90% case and reads naturally.

I'm also aware tools like kill-port (npm) exist — lsport is in that family but Python-native and adds the listing + TUI layer.

What I'd actually love feedback on

  • Code quality and project structure — this is my first OSS project, so blind spots are guaranteed
  • The kill confirmation flow — too noisy, or about right?
  • Windows support — happy to mentor anyone who wants to take a stab
  • Subcommand naming and UX

Repo: https://github.com/0xBroom/lsport PyPI: https://pypi.org/project/lsport/

MIT licensed. Issues and PRs are open. Tear it apart — I'd rather hear it now than later.

u/JohnHopeman — 15 hours ago