gitmyhub

how2

JavaScript ★ 5.8k updated 3y ago

AI for the Command Line

A command-line tool that finds shell commands by typing plain English questions in your terminal, with an AI suggestion mode and a StackOverflow search mode so you never need to leave the terminal.

JavaScriptNode.jsnpmHomebrewsetup: easycomplexity 2/5

how2 is a command-line tool that helps you find the right shell command without leaving your terminal. Instead of opening a browser, searching Google, and clicking through to a StackOverflow answer, you type something like how2 compress a file with tar and it shows you the command. It is designed as a natural-language alternative to man pages, the built-in Unix help system.

By default, how2 sends your query to an AI server that has been trained on Bash and PowerShell commands and returns a suggestion. The AI mode is free for up to five queries per day. Adding the -s flag switches to StackOverflow search mode instead, where it fetches the top answers for your question directly. After seeing an initial result, pressing the spacebar enters interactive mode, letting you browse through multiple StackOverflow questions and answers and select the most relevant one.

Installation options include Homebrew on macOS, npm (as a global install), a .deb package for Ubuntu and Debian, and prebuilt binaries for direct download. If you install via npm without administrator access, you can run it with npx how2 or set up a manual alias. Proxy environments are supported through standard HTTP_PROXY and HTTPS_PROXY environment variables.

The tool works well for common shell tasks but may produce unexpected output for unusual or very specific queries. The README suggests rewording the query if the first attempt does not return a useful result, and falling back to the StackOverflow mode when the AI result is not helpful. A paid subscription tier is available at the project's website for professional users who need more than five daily queries.

Where it fits