Home

Awesome

hackernews-TUI

hackernews_tui is a fast and customizable application for browsing Hacker News on the terminal.

hackernews_tui is written in Rust with the help of Cursive TUI library. It uses HN Algolia APIs and HN Official APIs to get Hacker News data.

Table of Contents

Install

Binaries

Application's prebuilt binaries can be found in the Releases Page.

Using cargo

Install the latest version from crates.io by running cargo install hackernews_tui --locked.

Docker image

You can download the binary image of the latest build from the master branch by running

docker pull aome510/hackernews_tui:latest

then run

docker run -it aome510/hackernews_tui:latest

to run the application. You can also use your local configuration file when running the image by running

docker run --rm -v ${CONFIG_FILE_PATH}:/app/hn-tui.toml -it aome510/hackernews_tui:latest

with ${CONFIG_FILE_PATH} is the path to the local configuration file.

Building from source

Run

git clone https://github.com/aome510/hackernews-TUI.git
cd hackernews-TUI
cargo build --release

to build the application, then run

./target/release/hackernews_tui

to run the application, or

ln -sf $PWD/target/release/hackernews_tui /usr/local/bin

to link the executable binary to /usr/local/bin folder.

Windows

Via Scoop

Run scoop install hackernews-tui to install the application.

macOS

Via MacPorts

Run sudo port install hackernews-tui to install the application.

Arch Linux

Run yay -S hackernews_tui to install the application as an AUR package.

NetBSD

Using the package manager

pkgin install hackernews-tui

Building from source

cd /usr/pkgsrc/www/hackernews-tui
make install

Examples

Demo

Demo videos of hackernews_tui v0.9.0 are available on youtube and asciinema

asciicast

Story View

Example of a Story View

Article View

Example of an Article View

Search View

Example of a Search View

Comment View

Example of a Comment View

Default Shortcuts

In each View, press ? to see a list of supported keyboard shortcuts and their functionalities.

Example of a Help View

The below sections will list the application's default shortcuts, which can be customized by changing the key mappings in the user's config file.

For more information about configuring the application's key mappings or defining custom shortcuts, please refer to the config documentation.

Global shortcuts

CommandDescriptionDefault Shortcut
open_help_dialogOpen the help dialog?
close_dialogClose a dialogesc
quitQuit the application[q, C-c]
goto_previous_viewGo to the previous view[backspace, C-p]
goto_search_viewGo to search view[/, C-s]
goto_front_page_viewGo to front page viewF1
goto_all_stories_viewGo to all stories viewF2
goto_ask_hn_viewGo to ask HN viewF3
goto_show_hn_viewGo to show HN viewF4
goto_jobs_viewGo to jobs viewF5

Edit shortcuts

CommandDescriptionDefault Shortcut
move_cursor_leftMove cursor to left[left, C-b]
move_cursor_rightMove cursor to right[right, C-f]
move_cursor_to_beginMove cursor to the begin of line[home, C-a]
move_cursor_to_endMove cursor to the end of line[end, C-e]
backward_delete_charDelete backward a characterbackspace

Scrolling shortcuts

CommandDescriptionDefault Shortcut
upScroll up[k, up]
downScroll down[j, down]
page_downScroll up half a page[d, page_down]
page_upScroll down half a page[u, page_up]
topScroll to top[g, home]
bottomScroll to bottom[G, end]

Shortcuts for each View

Story View shortcuts

CommandDescriptionDefault Shortcut
next_storyFocus the next storyj
prev_storyFocus the previous storyk
next_story_tagGo to the next story tagl
previous_story_tagGo to the previous story tagh
goto_storyFocus the {story_id}-th story{story_id} g
goto_story_comment_viewGo the comment view associated with the focused storyenter
open_article_in_browserOpen in browser the focused story's articleo
open_article_in_article_viewOpen in article view the focused story's articleO
open_story_in_browserOpen in browser the focused storys
next_pageGo to the next pagen
prev_pageGo the previous pagep
cycle_sort_modeCycle story sort moded

Article View shortcuts

CommandDescriptionDefault Shortcut
open_article_in_browserOpen article in browsera
open_link_in_browserOpen in browser {link_id}-th link{link_id} o
open_link_in_article_viewOpen in article view {link_id}-th link{link_id} O
open_link_dialogOpen link dialogl
Link dialog shortcuts
CommandDescriptionDefault Shortcut
nextFocus next link[j, down]
prevFocus previous link[k, up]
open_link_in_browserOpen in browser the focused link[o, enter]
open_link_in_article_viewOpen in article view the focused linkO

Comment View shortcuts

CommandDescriptionDefault Shortcut
next_commentFocus the next commentj
prev_commentFocus the previous commentk
next_leq_level_commentFocus the next comment with smaller or equal levell
prev_leq_level_commentFocus the previous comment with smaller or equal levelh
next_top_level_commentFocus the next top level commentn
prev_top_level_commentFocus the previous top level commentp
parent_commentFocus the parent comment (if exists)u
toggle_collapse_commentToggle collapsing the focused itemtab
voteToggle voting the focused item (requires authentication)v
open_article_in_browserOpen in browser the discussed articlea
open_article_in_article_viewOpen in article view the discussed articleA
open_story_in_browserOpen in browser the discussed storys
open_comment_in_browserOpen in browser the focused commentc
open_link_in_browserOpen in browser the {link_id}-th link in the focused comment{link_id} o
open_link_in_article_viewOpen in article view the {link_id}-th link in the focused comment{link_id} O

Search View shortcuts

In SearchView, there are two modes: Navigation and Search. The default mode is Search.

Search mode is similar to Vim's insert mode, in which users can input a query string.

Navigation mode allows the SearchView to behave like a StoryView of matched stories.

SearchView-specific key shortcuts:

CommandDescriptionDefault Shortcut
to_search_modeEnter Search mode from Navigation modei
to_navigation_modeEnter Navigation mode from Search mode<esc>

Configuration

By default, hackernews-tui will look for the hn-tui.toml user-defined config file inside

If not found such file, the application will fall back to use a set of default configurations.

User can also specify the path to config file when running the application with -c or --config option.

hackernews_tui -c ~/.config/hn-tui.toml

For further information about the application's configurations, please refer to the example config file and the config documentation.

Authentication

Users can authenticate their account by specifying username and password inside the hn-auth.toml file:

username=""
password=""

By default, the authentication file should be inside the same folder as the the general configuration file (hn-tui.toml), which can be configured by specifying the -a or --auth option.

Logging

hackernews-tui uses RUST_LOG environment variable to define the application's logging level (default to be INFO).

By default, the application creates the hn-tui.log log file inside the user's cache directory, which can be configured by specifying the -l or --log option.

Roadmap