Is there a way to query Stack Overflow directly from the command line and get back the most upvoted answer to the first question that comes up for that query?
I really mislike having to open up my browser whenever I want to brush up on my knowledge of writing RegExes for matching XHTML tags.
Yes, it is possible! Try out Benjamin Gleitzman’s excellent tool howdoi.
It works like this:
and the program will query StackOverflow for keywords "get stackoverflow answers inside a terminal", find the question that best matches these terms and return the code from the best answer to that question.
You can also add the
-aoption to get the full answer, not just the code. So to get an answer for your example query, you would do:Installation
If you have Python & pip installed, you can get it from the Cheese shop.
More help
Enter
howdoi -hfor complete usage instructions.