
Show HN: HNTerm – Browse Hacker News in the Terminal - ggerganov
https://github.com/ggerganov/imtui/tree/master/examples/hnterm
======
ggerganov
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](https://github.com/HackerNews/API)

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

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

~~~
ggerganov
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.

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

------
oneeyedpigeon
Woah, those are some big dates:
[https://bobbyjack.me/images/hackernews/hnterm.png](https://bobbyjack.me/images/hackernews/hnterm.png)

~~~
ggerganov
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 :-)

------
equalunique
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?).

~~~
ggerganov
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.

~~~
agustif
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

------
ducaale
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.

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

~~~
ggerganov
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](https://github.com/ocornut/imgui)

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

------
folkhack
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 =)

~~~
ggerganov
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.

~~~
folkhack
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!

~~~
dang
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](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.

~~~
protomikron
> 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!

~~~
dang
This still holds:
[https://news.ycombinator.com/item?id=16076041](https://news.ycombinator.com/item?id=16076041)

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

~~~
protomikron
Nice, thanks! :)

------
iddan
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

~~~
wlqlwlql
I think a dark mode would be great too

------
mjsir911
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?

~~~
krilly
You could trick it into using different colours like so:

[https://unix.stackexchange.com/a/46354](https://unix.stackexchange.com/a/46354)

------
oneeyedpigeon
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)

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

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

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

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

