Skip to main content

Hacker News in your terminal

Project description

Pyhn

Hacker News in your terminal.

Pyhn screenshot

Pyhn reads from the official Hacker News API (the public, read-only JSON API hosted on Firebase), so there is no HTML scraping. Results are cached locally, and each section is fetched concurrently and streamed into the list as it arrives, so the first page shows up almost immediately.

Features

  • Official Hacker News API (no scraping)
  • Progressive, streaming load with skeleton placeholders
  • Concurrent item fetching
  • Local cache manager
  • Top, Newest, Best, Ask, Show, Show Newest and Jobs stories
  • Customize all the colors
  • Customize all the keybindings
  • Default vim-like keybindings
  • Auto refresh support
  • Plays nice with tmux and screen (over ssh too!)
  • Open stories in your web browser
  • Mouse support
  • Python 3.10+
  • MIT license

Installation

Pyhn requires Python 3.10 or newer. It is a command-line app, so the recommended installs put it in an isolated environment on your PATH.

With uv (recommended):

uv tool install pyhn

With pipx:

pipx install pyhn

pyhn is available in the AUR.

Usage

Use help for all key bindings:

  • h, ?: Print help popup

Configuration

By default, the configuration file is in $HOME/.pyhn/config. It is created with the defaults below on first run; you can set key bindings, colors and more.

This is an example file:

[keybindings]
page_up = ctrl u
page_down = ctrl d
first_story = g
last_story = G
up = k
down = j
refresh = r
show_comments_link = c
open_comments_link = C
show_story_link = s
open_story_link = S,enter
show_submitter_link = u
open_submitter_link = U
reload_config = ctrl R
newest_stories = n
top_stories = t
best_stories = b
show_stories = d
show_newest_stories = D
ask_stories = a
jobs_stories = J

[interface]
show_score = true
show_comments = true
show_published_time = false

[settings]
extra_page = 3
cache = /home/youruser/.pyhn/cache
cache_age = 5
browser_cmd = __default__
# Refresh interval in minutes (default: 5, minimum: 1)
refresh_interval = 5

[colors]
body = default||standout
focus = yellow,bold||underline
footer = black|light gray
footer-error = dark red,bold|light gray
header = dark gray,bold|white|
title = dark red,bold|light gray
help = black|dark cyan|standout
skeleton = dark gray|default
domain = dark blue|default

Settings

  • extra_page how many extra pages of stories to load (30 stories per page)
  • cache_age minutes after which CacheManager considers the cache outdated
  • browser_cmd command used to open links (__url__ is replaced by the link)
  • refresh_interval minutes between auto refreshes (minimum 1)

The [interface] section toggles the optional score, comment-count and published-time columns.

Examples:

browser_cmd = lynx __url__
browser_cmd = __default__
browser_cmd = w3m __url__
browser_cmd = echo "[INFO] Open with w3m: __url__" >> /tmp/pyhn.log && w3m __url__

Key bindings

You can set different key bindings for the same action with a comma separator. Take a look at the urwid input manual.

Colors

Color options are written as foreground|background|monochrome. The background and monochrome parts are optional (e.g. yellow,bold||underline leaves the background at the terminal default).

foreground

  • colors: 'default' (use the terminal's default foreground), 'black', 'dark red', 'dark green', 'brown', 'dark blue', 'dark magenta', 'dark cyan', 'light gray', 'dark gray', 'light red', 'light green', 'yellow', 'light blue', 'light magenta', 'light cyan', 'white'
  • settings: 'bold', 'underline', 'blink', 'standout'

background

  • colors: 'default' (use the terminal's default background), 'black', 'dark red', 'dark green', 'brown', 'dark blue', 'dark magenta', 'dark cyan', 'light gray'

monochrome

  • settings: 'bold', 'underline', 'blink', 'standout'

For more information take a look at the urwid manual.

License

License is MIT. See LICENSE.

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

pyhn-0.4.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

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

pyhn-0.4.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file pyhn-0.4.0.tar.gz.

File metadata

  • Download URL: pyhn-0.4.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pyhn-0.4.0.tar.gz
Algorithm Hash digest
SHA256 335e510f04227bf2a0cfd9898a19c284e28db047d631fe784d5f5d497289c16a
MD5 25f3daa1ec85d4e6e0440ff69d1d9fa6
BLAKE2b-256 b7b864a6ebf94bb441bf7bbafa8dad5ea336aa68863ec87768d3a225f523e2cf

See more details on using hashes here.

File details

Details for the file pyhn-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyhn-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pyhn-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3302273cc58bd5874a48cd331988e13dfb438c611d72480ee45fdc0177b8a0d
MD5 9c53ffcae4592fda75eaa75158aba18e
BLAKE2b-256 00819ec2b7b4229d0538471e4f4ac8b6e04ecbb5e870d25bdc9c6952ca04446c

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