Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: HNTerm – Browse Hacker News in the Terminal (github.com/ggerganov)
139 points by ggerganov on Dec 15, 2019 | hide | past | favorite | 41 comments



This is a console application that I wrote for browsing HN in a terminal. It has an ncurses UI and uses libcurl to query the HN API [0]. Currently works on Linux and Mac. I also ported it to web with Emscripten's Fetch API so it can be easily demonstrated [1].

[0] - https://github.com/HackerNews/API

[1] - https://hnterm.ggerganov.com


This is awesome, but not sure why pressing o / O on mac (catalina) doesn't open anything.


I’m just calling system() with “xdg-open” and url as argument. This is what a quick google search told me can be used for openning a browser from a C++ program. Maybe “xdg-open” is not available on Catalina. It is on Mojave I think.


Use `open` instead of xdg-open on macOS.


Cool app

// And screenshot



Ooops, I expected C++'s std::chrono::time_point::time_since_epoch() to always return the Unix time.. Guess it is not always the case :-)


Should be fixed now. See https://github.com/ggerganov/imtui/issues/3 for more info


Thanks for this.

I love the concept, and would use it daily if there were features for adding/removing/viewing favorites. This is something that the official API doesn't support, so it's not something I'm faulting this application for. Impressive for sure.

Also +1 on wlqlwlql's dark-mode idea, although a color theme in general might be a better approach (but perhaps overly complicated?).


This might not be addressing your issue directly, but for my browser extension Refined Hacker News [1], once a user is logged-in in the browser site it is fairly simple to "construct" the favorite-ing endpoint URL. The URL endpoint is "/fave" and requires two query parameters: `auth` and `id`. "auth" is a random string that is unique for each story/comment and is generated from the HN server (it's required for authorization of the "favorite" request), and "id" is the story/comment's ID number.

The auth string of a story for "fave" is the same as the auth string for the "hide" and "flag" links (since they are already present, the links' hrefs contain that auth string), and so we can extract the auth string from their hrefs and use it for favoriting and un-favoriting.

Moreover, I've created a simple API which can be used to get all the favorited items of a user: https://github.com/plibither8/hn-faves-api

1: https://github.com/plibither8/refined-hacker-news


The "favorite"/"follow" function is something I was also thinking about. I have some ideas about it - something like an extra feed window where only favorited (and related) things show up.

Regarding color themes - these are super easy to add.


an easy way of doing it would be storin a default bookmarks.txt file wherever and use that outside of the account, love the concept.

Would love it for PH too


Wow, the vim keybindings are very intiutive. I just pressed O without thinking about it and it opened the highlighted link in a browser. although I miss using h and l for going right and left. also, I don't know about others but it took me some time to figure out the enter key to open comments page. maybe that should be mentioned in the help window.


In general your imtui library looks really nice. I may have to consider it for some future projects!


Thanks! FYI, underneath ImTui, it's 99% the Dear ImGui library [0] - ImTui is basically just a textual output wrapper.

[0] https://github.com/ocornut/imgui


Wonderful. Very solid engineering here, using the right tool for the job.


Looking at the API request counter/how it renders it seems like you're pinging the API for every news item? 43 for just the "news" and "show" sections seems pretty high.

If that were the case I'd be worried about hitting an API limit, etc.

Great concept though! Looks clean =)


It's just the way the API works - to get the details for a single story (i.e. title, score, user, time, etc.) you need a single API request. Once the stories are fetched, then you can query the API only for those that have changed.

I was wondering what is the API limit - I haven't hit it yet. Will see.


Gotcha - it's times like that that I go with an old-fashioned raw HTTP request and parse it with a DOM parsing engine. Sometimes the "web-facing API" (so-to-speak) is better than the official API.

Super cool project!


Yes, an API that is isomorphic to the website itself would be much easier to use. Our plan is for the next version of HN's API to simply serve a JSON version of every page.

In the meantime, if you scrape the HTML, please respect https://news.ycombinator.com/robots.txt and don't do it more than once per 30 seconds. HN's app server runs on a single core, so we don't have a lot of performance to spare! This is in the works to change as well.


> HN's app server runs on a single core, so we don't have a lot of performance to spare!

That's interesting. Is there any more information about HN's tech stack? I know it's built on top of the Lisp dialect Arc, but I wonder about the server specs and would be happy to be pointed at some resource.

Although I experienced HN being down, I guess the overall uptime and availability is pretty decent. Keep up the good work!


This still holds: https://news.ycombinator.com/item?id=16076041

Number of requests is closer to 5M per day now.


Nice, thanks! :)


HN uses Cloudflare, doesn’t it? I would’ve assumed reads would be heavily cached.


Not any more.


What made you switch / leave CloudFlare?


The desire to have fewer moving parts.


I stand corrected.


Few UX comments: 1. There are a few advanced features that are enabled by default that I think should be hidden by default: stats and multiple panes 2. It's unclear how to get back when entering an article


I think a dark mode would be great too


Thanks for the feedback - I agree those features should be disabled by default. Just wanted to have them enabled now so people don't accidentally miss them


That's nice! There are some other mentions about color themes, but I'm wondering if it could just respect my terminal's color theme with background & foreground colors?


You could trick it into using different colours like so:

https://unix.stackexchange.com/a/46354


Sure - will definitely add color theme options, and using the terminal's theme would be one of them


FYI works fine on mac but requires cmake (I downloaded and built cmake from source with no problems on 10.14.6, but other installation options are available)


What's wrong with browsing Hacker News in the browser?


Yeah I could see putting things like baseball game scores in a terminal, because you don't really want to be browsing mlb.com at work - but HackerNews should be considered work related if you're a dev.

If your dayjob doesn't allow you to spend 1 hour a day keeping up on tech news/interests, then maybe you need a better job.


Better keybindings?


What's wrong with browsing Hacker News in your terminal?


Just trying to figure out what problem this project is solving.


Tangentially related - I wish there were a way to browse HN in Acme.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: