Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Hnsh - Hacker News from the command-line (scottjackson.org)
61 points by scottjackson on Dec 7, 2009 | hide | past | favorite | 45 comments


I like it. But I already use elinks in a terminal (most current Linux distros make elinks availble).

Here is how I run it:

$ elinks news.ycombinator.com

Then:

  Select story/comment :  "Up" and "Down" arrows. 

  Open story/comment :   "Enter"
  
  Go back to previous page : "Back" arrow.
 
  Quit : "q"


Neat! I hadn't heard of elinks before. Sounds like a good idea. Do you use it for many sites other than news aggregation sites like HN and Reddit? Do normal sites render OK?


I never get tired of being amazed that Gmail works perfectly with elinks!


Mostly, they do. I use it for lots of web browsing, and most sites are fine, and it even obeys much of the styling, etc. However, some sites, like overcomingbias.com, get partially corrupted (like bad-decompression-corrupted, not looks-kinda-odd-corrupted), sometimes. Reloading often fixes the problem. I assume there's some issue with the gzip integration.


I thought facebook handled my attempt at using elinks with humor! "keep it real"


Nah, just HN. It's a minimalistic and clean enough site that elinks (and my eyes!) can handle.


I like this, but does it really make sense to call it a "command-line" application? I'd call it a terminal application (like w3m, lynx, etc). I can also type "firefox http://news.ycombinator.com/ at my shell, but I don't think that makes it a command-line app.


I'm not sure what the distinguishing features are between a command-line app and a terminal app (I think that it's pretty pedantic to say that there's a difference, though I'm all for pedantry and I'd love to know what the difference is).

I think hnsh is a command-line app. It uses text-based input to do things based on that input -- sometimes opening other applications, and sometimes printing things to the screen.


As I understand it, a command-line app is typically something which is only accessed from your shell's command line, like 'ls'. You can type 'ls' and follow it with whatever arguments you want to follow it with, but it will always land you back at your command prompt (excepting crashes or infinite loops, of course). It's user interface IS the command line.

A terminal app (or a console app), while also accessed from one's shell, is not reliant solely on the shell's command line. It can have an interface of it's own, like 'hnsh' does, or like 'qbasic' in DOS does (did?).

By these definitions, all command-line apps are a subset of terminal/console apps, and not the other way around.

Personally, I do not think the difference is pedantic, but the terms do seem to get confused and muddled together frequently.


My w3m version:

    w3m http://news.ycombinator.com

    image: http://bayimg.com/DAGbdAACJ
shortcuts:

    H : Help
    TAB: Move to the next link 
    ENTER: Go to the current link
    B: Go to the previous link
    move around the text: hjkl
You can use the mouse of course.


hnsh is a program I wrote to let you catch up with HN from the shell. You can browse the front page, open up stories and open up comments. There are a couple other nifty features, but they're all listed on the page for you to read, so there's no use re-posting them here.

Hacker News, all keyboard, no mouse. Let me know what you think, HN.

I'll have to head off in a while (it's just past midnight here in Australia), but I'll definitely get back to any comments I miss.


Feature request: proxy server support. Right now the script just fails with an urllib2.UrlError. FYI I posted the stack trace here:

http://quandyfactory.com/projects/32/stack_trace_for_hnshpy_...


Just to be clear, you're trying to run the program from behind a proxy, yeah?

Thanks for the stack trace -- having that makes a big difference :)

I'm not sure I can make it work with an arbitrary proxy, but I'm pretty sure I could get it to work with a proxy you know the address of. Proxies aren't my strong suit, sorry. We'll see what happens!


> you're trying to run the program from behind a proxy, yeah?

That's right.

> I'm not sure I can make it work with an arbitrary proxy

You could assume that users know their own proxy address (e.g. http://proxy.domain.com:80) and offer a prompt for them to input it. Then you can just save it in the config file.

I added an update to the stack trace page with some code for working with proxies:

http://quandyfactory.com/projects/32/stack_trace_for_hnshpy_...

Hope that helps!


Thanks a bunch!

It's getting pretty late now (just hit 3am), but check back at http://github.com/scottjacksonx/hnsh (or http://scottjackson.org/software/hnsh/) some time late tomorrow and the project should be hosted there, as well as your proxy fix.


Great stuff! I'll follow your github repository.


Surely a command line browser like lynx, links, w3m or whatever would achieve this (and more since you can read the original page too)?

It might also prod pg or whoever to use better markup so you don't see "[greyarrow]" as link text instead of "upvote".


You're right -- lynx would do it (and even better with the markup change). Would it do stuff like remember the stories you'd read or the way you like looking at stories though?

(totally legitimate question, btw -- I'm interested in this stuff.)


You should put this on github! Are you accepting patches?


I'm not accepting patches at the moment, but that's not out of fierce overprotectiveness of my code -- I just didn't think there'd be any demand for it.

I've joined github, and this will be the first thing that I put there, so check http://github.com/scottjacksonx or http://scottjackson.org/software/hnsh/ in a few days and we'll see what I did!


Sounds good. You should also license this code under some kind of open source license (GPL, Apache, etc.).


up that source code! i already want to submit some patches!



Update - the code has been uploaded to Github!

http://github.com/scottjacksonx/hnsh


This is really cool. A lot of people said text based browsers would probably do the trick without having to write a bunch of python code -- but I would guarantee you learned something in the process.

Good job scott! (nice name by the way)


Looks interesting, but it does defeat the distraction-limiting device of having the only browser in you office on the laptop across the room. With this, I can procrastinate from any terminal.


I can see it now -- a switch you flip that makes the program print "Do your work" to stdout every time you try to open a story.


There's no HN API, right? So, you have to screen-scrape?


Unfortunately, yeah, I'm just getting the HTML of the home-page and slicing and dicing it.

Oh, how I wish there was an API... I kept the HTML-getting stuff in its own class, so if HN ever adds an API, I can slot that right in there instead.


I haven't yet tried out HN on my new Droid, but I've found that I far prefer purpose-built apps over just using "normal" sites. For example, the twitter app is much easier for my fat fingers than using the twitter site via the Android browser. With an API,....


Is that the standard twitter site, the old m.twitter.com site for mobile phones or the new mobile.twitter.com for webkit based phones?

This is an area where webapps should already be competitive.


Oh...I'm new to the whole smartphone thing...I'll have to try mobile twitter.


Given that you're fetching, slicing and dicing, why can't you then provide an API? That would be uber-cool ...


The thing is, I could, but because I'm not at all related to HN in any official way, it would be up to me to change how the API gets data from HN whenever HN changes anything at their end. That would mean there'd probably be a delay between HN making changes and me making changes, during which time any applications using the API wouldn't work.

I'd happily do it with the blessing of the officials at Y Combinator :)


What's your implementation language?


Is the source going to be made available?


The source code is in the .zip file, in the hnsh.py file that you run. That's all there is -- it's only about 550 lines or so.


Maybe he means "What license is the code under?" (if any)


Oh man, here's the part where I show my total ineptitude when it comes to code licensing...

Anyone have a link to a quick guide to code licensing for total newbies?


You can start by looking at http://www.opensource.org/licenses/category

The first question you need to answer is whether you want a copyleft license[1], that requires all derivative works to be open sourced as well, or a more liberal license that allows one to use your code in a proprietary application.

If you are OK with a liberal license you probably want to pick either the BSD[2] or MIT[3] license. For example, Django uses a BSD license.

If you want a copyleft license you probably want to use GPL[4] or LGPL[5]

  [1] http://www.gnu.org/copyleft/
  [2] http://www.opensource.org/licenses/bsd-license.php
  [3] http://www.opensource.org/licenses/mit-license.php
  [4] http://www.opensource.org/licenses/gpl-license.php
  [5] http://www.opensource.org/licenses/lgpl-license.php


Does it allow you to track a comment thread?


At the moment, the most you can do with comments is open them up in your browser.

Could you be more specific about the feature you're describing? Comments are an area I'd like to look at expanding on. I guess you mean tracking whether or not there are new comments on a story?


If you're involved in a comment thread, the discussion stays alive better if you respond promptly. But how do you know if people when people have responded to your comments? You can refresh the page but if you have several threads on the go at the same time, this might not be practical.

Ideally:

1) highlight comments that are new since the last time I viewed the comments,

2) alert me when a new comment has been added a specific thread


Interesting ideas. They're the kind of thing I'd like to look at in the future. In the mean-time, I suppose you're aware of the "Threads" page for each user? http://news.ycombinator.com/threads?id=YOUR_USERNAME_HERE

I use that for keeping track of who replied to my comments and stuff like that.


Yeah, that page is certainly helpful.




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

Search: