
Show HN: how2 – stackoverflow.com from the terminal - csantini
https://github.com/santinic/how2
======
Mizza
Or the more mature 'howdoi' \-
[https://github.com/gleitz/howdoi](https://github.com/gleitz/howdoi)

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

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

~~~
metakermit
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`.

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

~~~
mixmastamyk
Yes, though easily fixed:

    
    
        alias howdoi="howdoi -a -c "
    

The other improvements from how2 being a curses app are helpful though.

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

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

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

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

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

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

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

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

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

------
skoczymroczny
Does it know how to parse HTML using regexes?

~~~
csantini
Not yet.

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

~~~
ihuman
This already exists:
[https://gkoberger.github.io/stacksort/](https://gkoberger.github.io/stacksort/)

------
jimmyppi
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](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)

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

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

------
redwards510
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!

~~~
vadskye
"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...)

------
haphazardeous
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!

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

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

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

[http://tex.stackexchange.com/questions/2275/keeping-
tables-f...](http://tex.stackexchange.com/questions/2275/keeping-tables-
figures-close-to-where-they-are-mentioned)

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!

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

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

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

------
parsethis
loving this! helps me stay in the terminal

------
anthk
apropos

