Skip to main content

Prettify and enrich ifconfig output: aligned tables, IP/MAC/scope annotations, OUI vendor lookup, live DNS/DHCP/route, and a 1h bandwidth graph.

Project description

ifpretty

Prettify and enrich ifconfig output — aligned tables, color, decoded flags, IP/MAC/scope annotations, OUI vendor lookup, live DNS/DHCP/route, a 1‑hour bandwidth graph, and run‑to‑run diffing. Built on rich.

ifpretty

The default is an essentials view: identity, routable IPs (with scope), gateway and throughput, with down / address‑less interfaces collapsed to one line. Pass -v for every field.

Install

pip install ifpretty

Requires Python ≥ 3.9. The only dependency is rich.

Usage

ifpretty                       # essentials view; runs `ifconfig` for you
ifpretty -v                    # verbose: every field + expand collapsed interfaces
ifpretty en0 en6               # limit to one or more interfaces
ifconfig | ifpretty            # or pipe ifconfig in yourself

ifpretty -r                    # --records : compact label/value record layout
ifpretty -t                    # --table   : single wide table, all fields (<=240 cols)

ifpretty -l                    # --live    : route, traffic, friendly names, DNS, DHCP (macOS)
ifpretty -c                    # --check   : ping the default gateway for latency (macOS)
ifpretty -w                    # --wan     : public IP / ASN / geo (opt-in; sends IP to ipapi.co)
ifpretty -d                    # --diff    : show what changed since the previous run
ifpretty -x                    # --explain : append a legend for the flags/options seen

ifpretty --record              # sample byte counters (run via cron to feed the 1h graph)
ifpretty --update-oui          # refresh the IEEE vendor database into the cache

Run it bare and it runs ifconfig for you; or pipe ifconfig in to control which interfaces to show. Flags compose (e.g. ifpretty -l -d -w).

What it adds

Always on (offline, deterministic):

  • Per‑interface role (loopback / Ethernet·Wi‑Fi / VPN·tunnel / bridge / …).
  • IP scope for every address — loopback / link‑local / ULA / private / global — plus IPv4 network + usable‑host count.
  • MAC kind (universal vs locally‑administered), OUI vendor (bundled IEEE registry, no network), shared‑MAC notes (e.g. bridge members), and EUI‑64 detection.
  • Media speed/duplex with a half‑duplex ⚠ warning; jumbo / sub‑1280 MTU notes.
  • Decoded flag/option/nd6 bitfields; IPv6 attributes aligned into columns.
  • A one‑line overview above the layout (interface count, default route, totals).

--live (macOS, cross‑references the system):

  • Default route + gateway, friendly hardware‑port names, per‑interface DNS and search domains, DHCP server + lease, traffic counters (bytes + packets) and error/collision counts.

--check: pings the default gateway and reports latency / unreachable.

--wan (external, opt‑in): looks up your public IP plus ASN/ISP/geo via ipapi.co and shows it in the overview. It sends your public IP to a third party, so it is strictly opt‑in; the result is cached ~1 h, times out fast, and degrades silently offline. --update-oui refreshes the vendor database from the IEEE registry into the cache (overrides the bundled copy).

--diff: every run records a snapshot of the stable interface state (up/down, addresses, MAC, mtu, media, gateway — not volatile counters) to snapshot.json. With --diff, ifpretty prints what changed since the previous run — interfaces added/removed, status flips, added/removed IPv4/IPv6 addresses — before the normal view.

1‑hour bandwidth graph: schedule the recorder, then per‑interface Unicode sparklines (and a link‑utilization gauge) appear automatically:

# once, e.g. in `crontab -e` — use the absolute path:
* * * * * $(command -v ifpretty) --record
1h in    ▁▁▁▂▄█▅▂▁▁▁▁   peak 10.0 Mbps
1h out   ▁▂▂▄▆█▄▂▂▁▁▁   peak 533.3 Kbps
link use ████░░░░░░     40% of 1000 Mbps

Environment

  • NO_COLOR=1 disables color; CLICOLOR_FORCE=1 forces it when piped.
  • IFPRETTY_HISTORY — bandwidth‑samples file (default ~/.cache/ifpretty/samples.csv).
  • IFPRETTY_CACHE — cache directory for the WAN lookup, refreshed OUI DB, and the diff snapshot (default ~/.cache/ifpretty/).

--live / --check / --record use macOS tools (route, netstat, networksetup, scutil, ipconfig, ping) and no‑op (or degrade) elsewhere; the parsing, formatting and offline enrichment work wherever you can pipe ifconfig output in.

Architecture

The package is split into focused modules (one responsibility each):

Module Responsibility
model dataclasses Inet / Inet6 / Interface
parse raw ifconfig text → interface model
enrich derivations, OUI, system (--live/--check), history, --wan, snapshot/diff
formatting model values → styled (rich‑markup) strings; layout field rows
render render strategies (boxed / records / table) + overview / legend / diff
cli acquire input → parse → enrich → render

Dependency direction: model ← parse, enrich ← formatting ← render ← cli (no cycles).

Development

python3 -m unittest discover -s tests   # 63 tests (snapshot + unit)
ruff check src tests && mypy src

Layout snapshots are pinned to golden files; regenerate intentionally with REGEN=1 python3 tests/test_ifpretty.py.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifpretty-0.8.0.tar.gz (417.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifpretty-0.8.0-py3-none-any.whl (407.4 kB view details)

Uploaded Python 3

File details

Details for the file ifpretty-0.8.0.tar.gz.

File metadata

  • Download URL: ifpretty-0.8.0.tar.gz
  • Upload date:
  • Size: 417.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ifpretty-0.8.0.tar.gz
Algorithm Hash digest
SHA256 58430e1d59783ab6985cd76465d6a7f5a16eca893fb6fa6d631a015e0174703d
MD5 ecc9a611ef6f49d3b9da2234e08b03aa
BLAKE2b-256 361c151dccbb30a8913861e4e1283cdbbdef5c0583c338ef88562d027db6fc3c

See more details on using hashes here.

File details

Details for the file ifpretty-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: ifpretty-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 407.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ifpretty-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec6828c045ac086ff7ba8eff7527456808aec5d39cda7cbefaba3e140773c2a5
MD5 d1c2e786d72407935ecea5e48145f2b0
BLAKE2b-256 2c83957151f8b42523f39291030190d49434a291ee6935ad67b740ea1fa854f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page