Git Product home page Git Product logo

how2's Introduction

how2: AI for your Terminal

how2 finds the simplest way to do something in a unix shell. It's like man, but you can query it in natural language. It uses a mix of AI code-completion and StackOverflow search.

It effectively replaces Chrome => New Tab => Google => Click on StackOverflow => Scroll Down to first answer.

Go to how2terminal.com for more info.

how2 AI for the Command-Line

Demo video

v5.mp4



Install

MacOSX (via HowBrew):

brew tap how2terminal/how2
brew install how2

With NPM:

sudo npm install -g how2

If you install it without sudo, then you have to run it with npx how2 or alias the command manually.

Ubuntu/Debian:

Download latest .deb and then run:

wget how2terminal.com/how2.deb
sudo dpkg -i how2.deb

Binaries:

Go to the latest release and download the binaries.



Usage

By default, how2 uses an external AI server to find the best unix command line suggestion. If you add the -s option instead, it will search StackOverflow for an answer.

how2 AI and StackOverflow mode

how2 -s example

After that you can press SPACE to go to the interactive mode, where you can choose a different stackoverflow question/answer.

how2 interactive mode

how2 interactive mode 2

How does it work?

Behind the curtain, the API use a couple of AI code-completion models retrained on Bash/Powershell commands. This is just the beginning, we are working on retraining the models to focus on the Command-Line experience. Currently, the AI mode is free for everybody up to 5 requests per day. If you are a professional user consider upgrading to a paid subscription.

How well does it work?

It is surprisingly useful once you get used to it! I've added it to all my servers and laptops and I use it daily. Sometimes, the model cannot find a solution and will result in unexpected output. In that case, try rewording your input, it often takes minor changes to get to a good solution. And, if it really doesn't work, just add -s to get the best answer on StackOverflow straight into the Terminal.

Copy-Paste with mouse

When you are in "interactive mode" (after you press SPACE), if you want to copy-paste more than one line you can:

  • press "p" to just print out the selected answer (easier to copy-paste)
  • use block-select: With Ubuntu try holding Ctrl+Alt before you select, or Alt+Cmd if you're in iTerm on Mac (thanks to @danielkop for this suggestion).

Can I use it behind Proxy ?

Yes, you need to use HTTP_PROXY or HTTPS_PROXY environment variables.

For example, you could alias the proxy settings in your ~/.bash_profile:

alias how2="HTTPS_PROXY='your_proxy:8888' how2"

how2's People

Contributors

chapeupreto avatar codyd51 avatar danielkopi avatar danyshaanan avatar foxboron avatar goibon avatar jericson avatar ksaldana1 avatar magicdawn avatar nathanepstein avatar paolocifariello avatar santinic avatar zippeurfou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

how2's Issues

Unable to Copy the Code

I am unable to copy the code from terminal when I am searching for another question with the SPACE and found an answer. Not able to select the code and copy it. Any help in there?

error after pressing space

every time I press space following error shown:

Press SPACE for more choices, any other key to quit.
TypeError: Invalid Version: null
    at new SemVer (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/semver/semver.js:279:11)
    at compare (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/semver/semver.js:566:10)
    at Function.gt (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/semver/semver.js:595:10)
    at /home/my-user/.npm-packages/lib/node_modules/how2/lib/updates.js:15:19
    at Request._callback (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/npm-latest/lib/npm-latest.js:53:5)
    at Request.self.callback (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/home/my-user/.npm-packages/lib/node_modules/how2/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)

Feature Request: Local Preferences

For nearly any issue of importance, there will be several answers. I would like the option to select my preference for a particular answer and be shown that answer automatically instead of the others for a particular query. This could be accomplished by storing a dictionary of queries with the preference value, or by tagging a priority number to the hash of the answer urls (treating untagged as a lower priority), each time an answer is marked up by me, it would increment the priority by 1 thus increasing the visibility of the answer in future queries.

Hotkey: `O` to "open" a list item (Same as `Enter`/`l`)

Since you use j/k for movement, and q to "go back", I was expecting o to open the selected item in a list. I later discovered that the l key does the same, but for some reason my fingers wanted o to open the list item. Perhaps user configurable hotkeys would be nice? Or at least mention hotkeys in --help or in the readme?

Cannot read property '1' of null

To reproduce (with or without quotes):

%: how2 youtube api check if copyright taken down
/home/foo/.node/lib/node_modules/how2/lib/utils.js:45
            site: matches[1],
                         ^
TypeError: Cannot read property '1' of null

TypeError

$ how2 python request headers

Cannot fetch answers from Stackoverflow.
TypeError: Cannot read property 'body_markdown' of undefined

Cannot connect to Google.

Error while trying to search for a query:

|(node:21174) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead. |Cannot connect to Google. Error: Error on response:Error: socket hang up : undefined

OS: Ubuntu 16.04
Node version: v6.3.1
npm version: 3.10.3
how2 version: 1.1.0

Undocumented "-i" option

In lib\index.js

if(argv.i) {
    how2.main(text, argv.l);
}
else {
    how2.magic(text, argv.l);
}

What's the purpose of -i? it's undocumented.
Should it be removed (along with how2.magic) or Added to readme.md and help?

Google rate limit kicking in

While issuing a query, the app failed with the following error:

⭐  how2 -l android launch activity in new task                                                      
-You are doing too many requests to Google. You need to wait a bit before trying again.`

If the app is using an API key shared across all users, it might be hitting a rate limit earlier than expected?

Implement voting

It'd be good to allow voting on questions and answers from this.

Not handling <kdb> balisa.

To reproduce :

how2 -l vi indent multiple lines quicly

Use the <kbd>></kbd> command. To indent 5 lines, <kbd>5</kbd><kbd>></kbd><kbd>></kbd>. To mark a block of lines and indent it, <kbd>V</kbd><kbd>j</kbd><kbd>j</kbd><kbd>></kbd> to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use <kbd>></kbd><kbd>%</kbd>.
....

It's really cumbersome to read but I don't know how it should be displayed on the cli.
Can a background color do the trick ?

Ability to copy text from SPACE bar options

When I click on the space bar for more choices and select an option, a new "window" opens up. It would be nice to be able to copy the text from what's displayed.

Thanks!

Google certificate issue when use inside company firewall

Is there a way to use http instead of https from google? I tried -k or --skip-ssl-validation but still got error:

Cannot connect to Google.
Error: Error on response:Error: unable to get local issuer certificate : undefined

When I disconnect from my company VPN, it's fine.

System package management

This is really nifty, but there's no way I would ever use sudo and let npm write to files and directories reserved for a real system-wide package manager. If however, it was available as an apt package, RPM, or ebuild, then adoption is more likely.

Implement text wrapping

Words get chopped off midway. Why not wrap at 80 columns or whatever the current width of the terminal?

TypeError: Cannot read property '1' of null

Found this issue while selecting an answer from the list of more answers.

Press SPACE for more choices, any other key to quit.
TypeError: Cannot read property '1' of null
    at Object.parseStackoverflowQuestionId (/usr/local/lib/node_modules/how2/lib/utils.js:45:26)
    at /usr/local/lib/node_modules/how2/lib/how2.js:20:32
    at ScrollableBox.<anonymous> (/usr/local/lib/node_modules/how2/lib/ui.js:66:9)
    at ScrollableBox.EventEmitter._emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:94:20)
    at ScrollableBox.EventEmitter.emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:117:12)
    at ScrollableBox.List.enterSelected (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/list.js:586:8)
    at ScrollableBox.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/list.js:119:14)
    at ScrollableBox.EventEmitter._emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:94:20)
    at ScrollableBox.EventEmitter.emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:117:12)
    at Program.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/screen.js:602:15)

"SyntaxError: Unexpected token <" when pressing space

Does how2 require a min version of node?

I did how2 scp from remote, and then pressed Space:

$how2 scp from remote
scp - How to copy a file from remote server to local machine?

The syntax for scp is:

If you are on the computer from which you want to send file to a remote computer:


   scp /file/to/send username@remote:/where/to/put

Here the remote can be a FQDN or an IP address.

On the other hand if you are on the computer wanting to receive file from a remote computer:


   scp username@remote:/file/to/send /where/to/put

scp can also send files between two remote hosts:


   scp username@remote_1:/file/to/send username@remote_2:/where/to/put

So the basic syntax is:


   scp username@source:/location/to/file username@destination:/where/to/put

You can read man scp (http://linux.die.net/man/1/scp) to get more idea on this.


Press SPACE for more choices, any other key to quit.
SyntaxError: Unexpected token <
    at Object.parse (native)
    at Request._callback (/Users/danqing/.nvm/v0.10.32/lib/node_modules/how2/node_modules/npm-latest/lib/npm-latest.js:49:23)
    at Request.self.callback (/Users/danqing/.nvm/v0.10.32/lib/node_modules/how2/node_modules/request/request.js:199:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/Users/danqing/.nvm/v0.10.32/lib/node_modules/how2/node_modules/request/request.js:1036:10)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/danqing/.nvm/v0.10.32/lib/node_modules/how2/node_modules/request/request.js:963:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)

Additional stackexchange sources

Scraped from http://stackexchange.com/sites?view=list#traffic

http://stackoverflow.com/
http://serverfault.com/
http://superuser.com/
http://meta.stackexchange.com/
http://webapps.stackexchange.com/
http://gaming.stackexchange.com/
http://webmasters.stackexchange.com/
http://cooking.stackexchange.com/
http://gamedev.stackexchange.com/
http://photo.stackexchange.com/
http://stats.stackexchange.com/
http://math.stackexchange.com/
http://diy.stackexchange.com/
http://gis.stackexchange.com/
http://tex.stackexchange.com/
http://askubuntu.com/
http://money.stackexchange.com/
http://english.stackexchange.com/
http://stackapps.com/
http://ux.stackexchange.com/
http://unix.stackexchange.com/
http://wordpress.stackexchange.com/
http://cstheory.stackexchange.com/
http://apple.stackexchange.com/
http://rpg.stackexchange.com/
http://bicycles.stackexchange.com/
http://programmers.stackexchange.com/
http://electronics.stackexchange.com/
http://android.stackexchange.com/
http://boardgames.stackexchange.com/
http://physics.stackexchange.com/
http://homebrew.stackexchange.com/
http://security.stackexchange.com/
http://writers.stackexchange.com/
http://video.stackexchange.com/
http://graphicdesign.stackexchange.com/
http://dba.stackexchange.com/
http://scifi.stackexchange.com/
http://codereview.stackexchange.com/
http://codegolf.stackexchange.com/
http://quant.stackexchange.com/
http://pm.stackexchange.com/
http://skeptics.stackexchange.com/
http://fitness.stackexchange.com/
http://drupal.stackexchange.com/
http://mechanics.stackexchange.com/
http://parenting.stackexchange.com/
http://sharepoint.stackexchange.com/
http://music.stackexchange.com/
http://sqa.stackexchange.com/
http://judaism.stackexchange.com/
http://german.stackexchange.com/
http://japanese.stackexchange.com/
http://philosophy.stackexchange.com/
http://gardening.stackexchange.com/
http://travel.stackexchange.com/
http://productivity.stackexchange.com/
http://crypto.stackexchange.com/
http://dsp.stackexchange.com/
http://french.stackexchange.com/
http://christianity.stackexchange.com/
http://bitcoin.stackexchange.com/
http://linguistics.stackexchange.com/
http://hermeneutics.stackexchange.com/
http://history.stackexchange.com/
http://bricks.stackexchange.com/
http://spanish.stackexchange.com/
http://scicomp.stackexchange.com/
http://movies.stackexchange.com/
http://chinese.stackexchange.com/
http://biology.stackexchange.com/
http://poker.stackexchange.com/
http://mathematica.stackexchange.com/
http://cogsci.stackexchange.com/
http://outdoors.stackexchange.com/
http://martialarts.stackexchange.com/
http://sports.stackexchange.com/
http://academia.stackexchange.com/
http://cs.stackexchange.com/
http://workplace.stackexchange.com/
http://windowsphone.stackexchange.com/
http://chemistry.stackexchange.com/
http://chess.stackexchange.com/
http://raspberrypi.stackexchange.com/
http://russian.stackexchange.com/
http://islam.stackexchange.com/
http://salesforce.stackexchange.com/
http://patents.stackexchange.com/
http://genealogy.stackexchange.com/
http://robotics.stackexchange.com/
http://expressionengine.stackexchange.com/
http://politics.stackexchange.com/
http://anime.stackexchange.com/
http://magento.stackexchange.com/
http://ell.stackexchange.com/
http://sustainability.stackexchange.com/
http://tridion.stackexchange.com/
http://reverseengineering.stackexchange.com/
http://networkengineering.stackexchange.com/
http://opendata.stackexchange.com/
http://freelancing.stackexchange.com/
http://blender.stackexchange.com/
http://mathoverflow.net/
http://space.stackexchange.com/
http://sound.stackexchange.com/
http://astronomy.stackexchange.com/
http://tor.stackexchange.com/
http://pets.stackexchange.com/
http://ham.stackexchange.com/
http://italian.stackexchange.com/
http://pt.stackoverflow.com/
http://aviation.stackexchange.com/
http://ebooks.stackexchange.com/
http://beer.stackexchange.com/
http://softwarerecs.stackexchange.com/
http://arduino.stackexchange.com/
http://expatriates.stackexchange.com/
http://matheducators.stackexchange.com/
http://earthscience.stackexchange.com/
http://joomla.stackexchange.com/
http://datascience.stackexchange.com/
http://puzzling.stackexchange.com/
http://craftcms.stackexchange.com/
http://buddhism.stackexchange.com/
http://hinduism.stackexchange.com/
http://communitybuilding.stackexchange.com/
http://startups.stackexchange.com/
http://worldbuilding.stackexchange.com/
http://ja.stackoverflow.com/
http://emacs.stackexchange.com/
http://hsm.stackexchange.com/
http://economics.stackexchange.com/
http://lifehacks.stackexchange.com/
http://engineering.stackexchange.com/
http://coffee.stackexchange.com/
http://vi.stackexchange.com/
http://musicfans.stackexchange.com/
http://woodworking.stackexchange.com/
http://civicrm.stackexchange.com/
http://health.stackexchange.com/
http://ru.stackoverflow.com/
http://rus.stackexchange.com/
http://mythology.stackexchange.com/
http://law.stackexchange.com/
http://opensource.stackexchange.com/
http://elementaryos.stackexchange.com/
http://portuguese.stackexchange.com/
http://computergraphics.stackexchange.com/
http://hardwarerecs.stackexchange.com/
http://es.stackoverflow.com/
http://3dprinting.stackexchange.com/
http://ethereum.stackexchange.com/

Tag releases

Hi,

can you use (ideally signed) tags for every release? This makes package maintainers life easier.

Thank you.

Change default language

It would be nice to either read the user's default shell, or read a dotfile in the ~ or ~/.config/how2 directory to to set default language.

I use the fish shell, so will never use the default language of Bash for how2.

Currently I've set an alias in my shell.

`later` in 'updates.js' uses string comparison instead of int comparison.

https://github.com/santinic/how2/blob/master/lib/updates.js#L9-L17

 function later(a, b) {
        var as = a.split('.');
        var bs = b.split('.');
        for(var i=0; i<3; i++) {
            if(as[i] > bs[i])
                return true;
        }
        return false;
    }
later('1.0.9','1.0.10')

This returns true, as the string '9' is later lexicographically than the string '10'.

This can be resolved using semver as can be seen here.

If this seems right, I could make the changes with a PR.

osx: TypeError: Cannot read property 'prototype' of undefined

how2 -l bash zip only jpg

/usr/local/lib/node_modules/how2/node_modules/devnull/transports/transport.js:59
Transport.prototype.__proto__ = EventEmitter.prototype;
                                            ^

TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/devnull/transports/transport.js:59:45)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/devnull/transports/stream.js:8:17)
    at Module._compile (module.js:571:32)

Node -v
v7.2.1

Replace Google's API

Google is a known privacy violator and PRISM-contributor. It would be nice to have this search go through DuckDuckGo or (ideally if possible) searx.

None of the answers I got make sense

How does how2 resolve search queries? Here is what I searched (just to give it a spin)

Q: $how2 scala read file
A: bash - Command substitution in for loop not working

Q: $how2 android launch activity in new task
A: bash - When I run ./command.sh & the background task is ...

Q: $how2 how to use how2
A: software installation - how to install .git file?

Love the premise of the project, but its answers are completely off.

How to uninstall how2?

I used npm to uninstall but failed.
$ npm uninstall how2
npm WARN ENOENT ENOENT: no such file or directory, open '/Users/JonyMac/package.json'
npm WARN EPACKAGEJSON JonyMac No description
npm WARN EPACKAGEJSON JonyMac No repository field.
npm WARN EPACKAGEJSON JonyMac No README data
npm WARN EPACKAGEJSON JonyMac No license field.

So how to remove how2 and its all dependencies?
Thanks.

/usr/bin/env: node: No such file or directory

Hey, I am trying to install on ubuntu 14.04, I had to use sudo, do to permissions issues mentioned. It installed successfully, however now when I run the the command it gives the error:
/usr/bin/env: node: No such file or directory

any ideas?

Include a link to the answer

By default, answers provided by how2 come from Stack Overflow, which has an attribution policy. It's pretty typical to include a comment with a link to the SO answer when using code, so it would be good to include the answer link in the output.

I hacked together a patch that adds the link to both the initial display and the menu selection. I'd be happy to submit a pull request if that would be desirable.

(Disclosure: I work as a Community Manager for Stack Overflow.)

How2 crashes when pressing space while viewing a question with no answers

Steps to reproduce:

  • Ask a question
  • Press space to see more choices
  • Find a question with no answers
  • Press space on the empty answer list

screen shot 2016-03-15 at 10 24 29

TypeError: Cannot read property 'body_markdown' of undefined
    at Object.showAnswer (/usr/local/lib/node_modules/how2/lib/ui.js:177:46)
    at /usr/local/lib/node_modules/how2/lib/how2.js:120:20
    at ScrollableBox.<anonymous> (/usr/local/lib/node_modules/how2/lib/ui.js:151:9)
    at ScrollableBox.EventEmitter._emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:94:20)
    at ScrollableBox.EventEmitter.emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:117:12)
    at ScrollableBox.List.enterSelected (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/list.js:586:8)
    at ScrollableBox.<anonymous> (/usr/local/lib/node_modules/how2/lib/ui.js:155:21)
    at ScrollableBox.EventEmitter._emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:94:20)
    at ScrollableBox.EventEmitter.emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:117:12)
    at Program.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/screen.js:603:15)

TypeError: process.stdin.setRawMode is not a function

"Cannot fetch answers from Stackoverflow.
TypeError: process.stdin.setRawMode is not a function."

This message occurs every time I use the command how2.
I'm using windows 10 and using Git Bash command line.

Kind regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.