Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: how2 – stackoverflow.com from the terminal (github.com/santinic)
272 points by csantini on Feb 22, 2016 | hide | past | favorite | 43 comments



Or the more mature 'howdoi' - https://github.com/gleitz/howdoi


howdoi beahaves in a very different way. It doesn't give you unix.stackexchange.com answers by default:

$ howdoi unzip bz2

readcsvbz2file <- read.csv(bzfile("file.csv.bz2"))

how2 switches API depending on what language you are querying.


It's also much nicer looking and more interactive, FWIW...I also agree with its defaults.

    $ howdoi inverse grep a file
Simply pops this up:

      $ grep -L "foo" *
...apparently it scrapes the answer result and print the last occurrence of code-formatted text.

Whereas `how2` pretty-prints the entire answer, narrative and code, so I know what the respondent was actually addressing. FWIW, both tools don't address what I want (I was thinking `grep -v`)...but that's not a fault of the tools, but of the ambiguity in how we ask questions. `howdoi` has far more faith in there being "Just One Answer"...where `how2` let's you move very quickly between the relevant choices, giving you the right amount of context to navigate.

Well done OP!


Uh oh,

    ~> howdoi  parse json python
    {"maps":[{"id":"blabla","iscategorical":"0"},       {"id":"blabla","iscategorical":"0"}],
    "masks":{"id":"valore"},
    "om_points":"value",
    "parameters":{"id":"valore"}
    }
Yep can't agree more.


You can also get the whole answer in `howdoi` by passing the `-a` flag:

    howdoi -a inverse grep a file
Even basic syntax highlighting is supported using `-c`.


The difference is that it's verbosity and pretty-print is the default for how2, and I think that's the more sensible choice, because it saves me the trouble of having to remember how to invoke it with flags just to get decent output from it. By the time I need to seek help, I'm willing to put up with verbosity.


Yes, though easily fixed:

    alias howdoi="howdoi -a -c "
The other improvements from how2 being a curses app are helpful though.


Funny enough, `how2 grep` does give you want you want.


I like how they both include the same xkcd comic in the readme.


Yay python, don't need to install (another) giant runtime. Looks like healthy competition though.


Nice! Installed it and will now make it part of all the computers I use.

I found this funny:

> It uses Google and Stackoverflow APIs, because Stackoverflow search on its own doesn't works as well.

It doesn't really make sense why Google would be a better entrance point into StackOverflow's content -- but it is -- as I imagine the Google algorithm uses SO's API itself to incorporate SO's data into pagerank in some way (the tags, the points, etc.)...OTOH, after landing on a particular question via Google, if it isn't the thing I actually need, I find SO's list of related questions to almost always be on point.


Try Stackexchange search, it never gets you what you are looking for, they are just using some kind of Elastic Search.

I think Google instead indexes SO pages as any html, and does a much better job at figuring out what "unzip .bz2" means.


Google ignores special characters though - that makes it really hard to search for some things.


Not always. Since a year or two, I'm seeing they take into account many special characters:

https://www.google.com/search?q=.

https://www.google.com/search?q=.bz2 and https://www.google.com/search?q=bz2 are different, for instance.


I think google flags accounts as programmers and treats their searches differently. If I'm logged out of Google, searching for programming questions sometimes leads to sites on completely unrelated topics. Whereas when I'm logged into my account, from which 99% of my searches are programming intensive, I get all relevant programming results.


Google does this with all areas of interest. Politics, knitting, cat videos, programming etc. Sometimes it is useful sometimes it will re-enforce an echo chamber effect.


IME, Google's search is better than 99.9% of internal site searches.


Which is weird because a site's designers _know_ which parts of the content are relevant.


I don't think it's weird at all. Google has some of the brightest search minds and years of experience; an site's team is lucky to have someone on staff who even knows what porter-stemming is.


Ok, true. I've personally found that I can kick Google's butt simply because Google cannot trust the site's creator. This puts them at a big disadvantage right out of the gate.


It's not that weird. I know what content is on my site, but fuzzy matching the vast variety of input strings is non-trivial to do well. (Emphasis on 'to do well' because there are a lot of ways to get it working but poorly.)


At first, I thought 'why2'?!

But then I saw the video, the way you can specify a language, and the nice format that results are displayed in, along with the option to see more options - this is actually quite nice!

It would be good to have the option to use it with Server Fault (also from StackExchange network) too.


Over the long run, if I'm living in the terminal rather than the browser, I probably will be better off learning to be effective finding help via `man` pages rather than taking on a dependency on a latent network connection and "possibly" relevant content...and node and npm and javascript.

In the short run, a tool like this may make it easier to get to the point where I am living in the terminal.


man can't help with many/most? languages. Though I agree a node dependency on lean computers is too much.


My first reaction ("Wowza!") was tempered by the fear that this sort of intervening layer may erode participation (and thus quality) of Stack Overflow. I suppose such a thing will never be popular enough to make this sort of effect.


Does it know how to parse HTML using regexes?


Not yet.


The next logical step is stackoverflow-powered code generation :)



Another alternative that just searches google (or bing if you want to go crazy) and extracts commands from the search hits: https://github.com/jimmyppi/searchcmd

  $ searchcmd "unzip bz2"
  .....
  tar xjvf        (michaelangela.wordpress.com, superuser.com)
  bunzip2 filename.bz2    (cyberciti.biz, linuxquestions.org)
  tar xvjf filename.tar.bz2       (superuser.com)
  bzip2 -d filename.bz2   (superuser.com)
  bzip2 -dk filename.bz2  (superuser.com)


Very nice. I much prefer this to howdoi.

A couple suggestions:

Does the `-l lang` flag correspond to stackoverflow tags which aren't necessarily limited to languages?

This should be specified because the right tag can significantly increase the quality of search results.

Also, it would be nice to have a keyboard shortcut that opens a question/answer in the browser. That way I can easily vote.


I'm not currently using tags, thank you for the suggestion. Not sure is available in the SO api, I'll check.

The keyboard shortcut is not hard to add. You could do it yourself :P


This is awesome! I have one burning question though: what is the proper -l lang parameter to use for Windows consoles? I tried:

how2 -l windows enable tab completion

and got nothing. "PowerShell" and "batch" bring back results, but I am drawing a blank on what to call the Windows Shell (cmd.exe). Thanks!


"how2 -l cmd change directory" works for me. "how2 -l cmd enable tab completion" still returns nothing, though; I think that's just a query it can't answer. (A quick manual search returned totally unhelpful results, so I wouldn't blame how2 for that...)


Saw this earlier this morning but just had to use it and boom! It worked perfectly. I really like the idea of using things on the console and the user interface is nice and sleek. would love to see this getting even better over time!


Text web browsers also make a lot of stuff like this reasonably easy inside a terminal. Someone mentioned http://elinks.or.cz/ a while ago.


Awesome! It would be great if I could use it to query any stackexchange site, like TeX, for instance. Like `how2 prevent table from floating -s tex` would search on tex.se


Actually that answer would be on tex.stackexchange.com.

http://tex.stackexchange.com/questions/2275/keeping-tables-f...

I'm not supporting this yet, let's see if I can make it work so that it uses also other stackexchange.com domains.

Thanks for the suggestion!


I believe tex.stackexchange.com is what GP meant by "tex.se", as in "tex.StackExchange"


How does it perform the natural language processing in the search? Or does it rely on stackoverflow for that?


it uses Google. Because stackoverflow doesn't give you what you want.


loving this! helps me stay in the terminal


apropos




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

Search: