Live data from Hacker News

Show HN: Get answers for shell commands from GPT3 from your terminal

github.com

41–50 of 97 posts

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#41

Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it) The example in the project readme is imo already a bad example. $ ai ask "Check process running on port" Answer Command i…

Geez you use this tool for quick answers, it's not a manual specification. Do you also hate the CPU cache because it doesn't always point to correct memory?

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#42

Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it) The example in the project readme is imo already a bad example. $ ai ask "Check process running on port" Answer Command i…

the example question is also part of the prompt

> 'Correctly answer the asked question. Return \'Sorry, Can\'t answer that.\' if the question isn\'t related to technology.\n\nQ - get into a docker container.\nA - `docker exec -it mongodb`\n\nQ - Check what\'s listening on a port.\nA - `lsof -i tcp:4000`\n\nQ - How to ssh into a server with a specific file.\nA - `ssh -i ~/.ssh/id_rsa user@127.0.0.1`\n\nQ - How to set relative line numbers in vim.\nA - `:set relativenumber`\n\nQ - How to create alias?\nA - `alias my_command="my_real_command"`\n\nQ - Tail docker logs.\nA - `docker logs -f mongodb`\n\nQ - Forward port in kubectl.\nA - `kubectl port-forward 8080:3000`\n\nQ - Check if a port is accessible.\nA - `nc -vz host port`\n\nQ - Reverse SSH Tunnel Syntax.\nA - `ssh -R :: @`\n\nQ - Kill a process running on port 3000.\nA - `lsof -ti tcp:3000 | xargs kill`\n\nQ - Backup database from a mongodb container.\nA - `docker exec -it mongodb bash -c "mongoexport --db mongodb --collection collections --outdir backup"`\n\nQ - SSH Tunnel Remote Host port into a local port.\nA - `ssh -L :: @`\n\nQ - Copy local file to S3.\nA - `aws s3 cp s3:///`\n\nQ - Copy S3 file to local.\nA - `aws s3 cp s3:/// `\n\nQ - Recursively remove a folder.\nA - `rm -rf `\n\nQ - Copy a file from local to ssh server.\nA - ` scp /path/to/file user@server:/path/to/destination`\n\nQ - Curl syntax with port.\nA - `curl http://localhost:3000`\n\nQ - Download a file from a URL with curl.\nA - `curl -o `\n\nQ - Git commit with message.\nA - `git commit -m "my commit message"`\n\nQ - Give a user sudo permissions.\nA - `sudo usermod -aG sudo `\n\nQ - Check what\'s running on a port?\nA - `lsof -i tcp:`\n\nQ - View last 5 files from history\nA - `history | tail -5`\n\nQ - When was China founded?\nA - Sorry, Can\'t answer that.\n\nQ - Pass auth header with curl\nA - `curl -H "Authorization: Bearer " `\n\nQ - Filter docker container with labels\nA - `docker ps --filter "label="`\n\nQ - When was Abraham Lincon born?\nA - Sorry, Can\'t answer that.\n\nQ - Get into a running kubernetes pod\nA - `kubectl exec -it bash`\n\nQ - Capital city of Ukrain?\nA - Sorry, Can\'t answer that.\n\nQ - ';

so you would expect it to answer it "correctly"

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#43

Earlier quoted context omitted.

I sort of agree wrt quoting. Most people's solution is just "well don't use spaces or dollars or whatever in your filenames!" which is obviously shit. But on the other hand I think the ultimate blame lies with Bash for being so shitily designed that you can make basic quoting mistakes and it works most of the time. Real programming languages don't have that issue.

It's not a real programming language tho

Yeah! REAL programmers program only in the REAL programming languages like ${MY_FAVORITE_LANG}. Bash? More like - Bah!.

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#46

Earlier quoted context omitted.

I sort of agree wrt quoting. Most people's solution is just "well don't use spaces or dollars or whatever in your filenames!" which is obviously shit. But on the other hand I think the ultimate blame lies with Bash for being so shitily designed that you can make basic quoting mistakes and it works most of the time. Real programming languages don't have that issue.

It's not a real programming language tho

true, but nothing (besides how entrenched sh is) prevents replacing it with a real language. you don't need to use a posix shell in your terminal, any REPL that can launch executables will do. i used tclsh as my shell for a while, for instance.

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#47

Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it) The example in the project readme is imo already a bad example. $ ai ask "Check process running on port" Answer Command i…

lsof is available on Mac's by default, ss is not, so significantly smaller depends on your platform I guess. I believe ss is not available for Mac at all, where as lsof is widely available.

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#48

Serious question. Why npm? I mean it's a command line tool; why buy in to the JavaScript ecosystem?

I'm a Frontend dev that's why I used JS but I can also publish to brew or as a single binary as the framework that I used (oclif) allows it. I was too lazy to publish it though.

The code is open-sourced please feel free to raise a PR. https://github.com/abhagsain/ai-cli

Re: Show HN: Get answers for shell commands from GPT3 from your terminal

#50

Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it) The example in the project readme is imo already a bad example. $ ai ask "Check process running on port" Answer Command i…

The other alternative is the top result for the Google search of that question.

It's not clear to me that this tool is a win over that method.

Post reply on HN