12 ms·
Using ChatGPT to make Bash palatable
- waynesonfire 4y agoyeah, game changer. it's deprecated having to click on links for common use-cases and not only that, it's improved it by more than 10x. can't wait to see this technology evolve.
- naderkhalil 4y ago100%, also just looking up dev docs for frameworks. Something like "write a post API in Golang's Gin framework" instead of looking up what that syntax was again
- john2x 4y agoIt's semi-replaced Google and StackOverflow for me. It's like having an interactive rubber duck https://en.wikipedia.org/wiki/Rubber_duck_debugging https://en.wikipedia.org/wiki/Rubber_duck_debugging
- worldsayshi 4y agoI try to use it like this sometimes but then I realise I now have two problems. I have to debug my own code and its code.
- someguy101010 4y agoit can usually debug itself if you give it an error message
- czzr 4y agoAssuming the problem with the code causes an error message. That’s actually the easier case - the hard case is incorrect logic but syntactically ok.
- naderkhalil 4y agoIt's surprisingly good at helping figure out what went wrong. Try asking it "something went wrong and I'm not sure what. What should we try next?"
- tottenval 4y agoGithub Copilot can do this too.
- naderkhalil 4y agoTotally! I found ChatGPT to be more helpful in this use case since it outputted full code snippets instead of generating it line by line. The context was also extremely valuable in making iterations (like "make it work for mac")
- generalizations 4y agoChatGPT has been amazing for all kinds of programming-adjacent things, even in my line of work where I asked it for help modifying the config file for a selfhosted gitlab instance. > But [Bash] fucking sucks. Like, it’s truly awful to write [...] As an aside, considering how basic the shell script actually was, I think this is a great example of being so intimidated by something that you don't actually try and use it - until you do, and discover it wasn't actually that bad. The hardest part was just discovering the incantations for interacting with Chrome - which was a fantastic demo of the power of ChatGPT.
- SpencerMLevitt 4y agothat's a great point - totally agree on just gettin over the hump of intimidation to try it, and chatgpt makes that hump trivial
- yamtaddle 4y agoBash isn't that bad... except there are 20 ways to do anything and 18 of them are wrong, but only 1% of online examples will use either of the two correct approaches and simply reading docs won't always clue you in about how the technique or syntax it's describing is actually subtly wrong and you should ~never use it.
- jakogut 4y agoI find integrating shellcheck into my text editor was one of the best things I've done for increasing my productivity when writing shell scripts.
- danielheath 4y agoYep - in the same way that you want govet, eslint, rubocop etc - but to a higher degree, because bash hides subtle bugs as soon as you use a variable without knowing the quoting rules.
- sureglymop 4y agoYes, i did the same! I also recommend following Stephane Chazelas on stackoverflow. The guy is a shell wizard who writes multiple quality answers a day. He's also the guy who found the "shellcheck" vuln some years ago. Learned a lot by reading the RSS feed of his SO profile every day.
- olalonde 4y agoI don't understand how people can look at this and still claim that it's not doing any "actual reasoning".
- foobarqux 4y ago"actual reasoning" doesn't mean anything concrete, until you define what you are talking about it can't be the basis of a question you can meaningfully answer.
- crabmusket 4y agoI think Deutsch in The Beginning of Infinity has a lot to say about this, but I find it really hard to reproduce and summarise. Chapter 7, "artificial creativity" addresses the subject at length, here's Deutsch's own summary of it: > The field of artificial (general) intelligence has made no progress because there is an unsolved philosophical problem at its heart: we do not understand how creativity works. Once that has been solved, programming it will not be difficult. Even artificial evolution may not have been achieved yet, despite appearances. There the problem is that we do not understand the nature of the universality of the DNA replication system. He describes personhood, people, as "creative, universal explainers". That's his dividing line between what a child can do, and what LLMs cannot do. We don't know how a child works, but we do know how LLMs work.
- foobarqux 4y agoWhile it's true that we don't know how intelligence/creativity/reasoning "works" there's an even more basic problem: It's not a well formed notion. "The result is that there is no hard problem… You can’t look for the answer to a problem unless you say here are the things I want to answer. If the things you want to answer have no formulation there is no problem.” (Chomsky, about the question of consciousness)." “There is a great deal of often heated debate about these matters in the literature of the cognitive sciences, artificial intelligence, and philosophy of mind, but it is hard to see that any serious question has been posed. The question of whether a computer is playing chess, or doing long division, or translating Chinese, is like the question of whether robots can murder or airplanes can fly — or people; after all, the “flight” of the Olympic long jump champion is only an order of magnitude short of that of the chicken champion (so I’m told). These are questions of decision, not fact; decision as to whether to adopt a certain metaphoric extension of common usage. "There is no answer to the question whether airplanes really fly (though perhaps not space shuttles). Fooling people into mistaking a submarine for a whale doesn’t show that submarines really swim; nor does it fail to establish the fact. There is no fact, no meaningful question to be answered, as all agree, in this case. The same is true of computer programs, as Turing took pains to make clear in the 1950 paper that is regularly invoked in these discussions. Here he pointed out that the question whether machines think “may be too meaningless to deserve discussion,” being a question of decision, not fact, though he speculated that in 50 years, usage may have “altered so much that one will be able to speak of machines thinking without expecting to be contradicted” — as in the case of airplanes flying (in English, at least), but not submarines swimming. Such alteration of usage amounts to the replacement of one lexical item by another one with somewhat different properties. There is no empirical question as to whether this is the right or wrong decision. -- Chomsky"
- mozman 4y agoI find bash to be pretty awesome, it’s super easy for an old hat like me to use. It just works and it has been mostly unchanged, two core principles more projects should consider.
- SpencerMLevitt 4y agoThis is an awesome walkthrough and gets me thinking about all the other automation tasks I could get done with ChatGPT-driven bash scripts... can take this same approach to context switching for actual apps. For ex: "dev" branch can open up vscode, terminal windows, linear, server logs, etc, while "marketing" branch can open up slack, chrome (to email), twitter, notion, etc
- naderkhalil 4y agoChatGPT has opened my eyes to how powerful Bash can be. Interesting idea about branching full workflows and not just the browser.
- raverbashing 4y agoSo the author complains about bash, but uses zsh They also basically uses the chrome cmdline commands and blames bash for that being bad Your problem doesn't seem to actually be bash (but chatgpt really makes it super easy)
- alecfong 4y agoI find it interesting how much harder it is to grok bash/sh/zsh than other languages I’ve learned. Off the top of my head it may be tooling like the lack of linting, or maybe it’s just experience as I avoid complexity like the plague when writing bash which sounds like a self fulfilling feedback loop. Gpt does seem to unblock this mental burden a bit which has me excited for its potential when it comes to education/teaching.
- geysersam 4y agoSomething about the quoting / unquoting can get really difficult to reason about. I'm rarely exactly sure how the language constructs work, even the for loop and the if statement. The syntax is complex compared to most other languages, and subtle differences can give totally different results. PICK = can you THE=tell the RIGHT=difference\ between WHAY="all of" TODO='these versions?'
- cerved 4y agoyes
- Izkata 4y agoexport YOU_FORGOT='this one' (Hint: it's most similar to your second one)
- cerved 4y agothis has nothing to do with quoting also='another way to pass variables to child scopes' sh -c "echo $also"
- Izkata 4y agoNeither of those are passing variables, those are setting environment variables. Bash (probably most shells?) mixes its variables with environment variables, and "export" is how you promote a bash variable to an environment variable. The inline version (GGP's [THE=tell the] version) sets the environment variable only for that one executable, while an exported one persists. Also I'm guessing you didn't test that, you got the quoting wrong (it prints nothing, the second one should be single quotes) ;)
- guites 4y agoThis is a great example of how someone with little programming knowledge could leverage an AI into building simple scripts. Lately I've been encouraging my friends into trying just that. If the poster would want, for example, to save all current tabs when switching context (going from dev to marketing, for example), this would quickly turn into a more involved debugging/prompting question.
- naderkhalil 4y agoThat would be a great follow on. I posted the repo if you want to leave any feedback or help me continue building it out: https://github.com/brevdev/dev-browser https://github.com/brevdev/dev-browser
- jrochkind1 4y agoI'm pretty damn impressed with this one. The osa-script thing for Mac even, wow.
- jrvarela56 4y agoI just bought a Streamdeck (https://www.amazon.com/Elgato-Stream-Deck-Controller-customizable/dp/B06XKNZT1P https://www.amazon.com/Elgato-Stream-Deck-Controller-customi...) for Cybermonday and attached bash scripts similar to those mentioned by the author to buttons next to my keyboard. It is delightful.
- user3939382 4y agoWhat action type do you use for your script? "Open"?
- jrvarela56 4y agoYeah open works, you can also create a multiaction to mix-and-match with other actions or scripts in between.
- Someone1234 4y agoI've done a similar thing on Windows and Powershell (via Open). Only limitation is it still spawn a terminal window even if briefly (enough to mess with focus however). powershell -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& { // Command(s) }" In particular I use it with this Powershell Script: https://stackoverflow.com/questions/21355891/change-audio-level-from-powershell https://stackoverflow.com/questions/21355891/change-audio-le... via e.g.: "& { C:\[Path To Script]\SetVolume.ps1; [audio]::Volume = 0.4 }" For 40% and so on.
- joenot443 4y agoThis is a neat product! What kinds of scripts do you have it set up to run?
- this_steve_j 4y agoThanks for the idea! I just found a Streamdeck from a past Cyber Monday when I was cleaning out my closet.
- user3939382 4y agoI was just commenting to a friend how annoying it is that macOS aliases can't add flags to executables like you can easily do in Windows shortcuts since, what? Windows 95? If you want to launch Chrome with flags through your dock/UI you have to compile an AppleScript to an .app. It's crazy.
- cerved 4y agoI don't use osx but surely you can create aliases just like in Linux and BSD?
- user3939382 4y agoNope. macOS aliases suck. It’s a binary unmodifiable file that can only point to a file, it can’t specify anything additional.
- DangitBobby 4y agoIs there a reason you can't add a script to your path and alias that? #!/usr/bin/env bash my-command --flag --another-flag $@
- varenc 4y agoAs far as I know, you can’t get an executable script like that to act like an app that’s launchable when double clicked from Finder or clicked the Dock. Even though it’s executable.
- DangitBobby 4y agoI just tried it, seems to work! Make your script with custom options, mark it as executable, make an alias for it within finder, and drag that into your dock.
- battles 4y agoYou can create a folder with a '.app' extension and put the script in there. Just make sure the script is executable with chmod and remove the '.sh' extension.
- civopsec 4y ago> Bash is available everywhere When you have AI but you don’t have permission to use a package manager.
- 63 4y agoThis is a relatively common use case for browsers that's usually solved by tab groups. I'm happy the author learned bash and leveraged new tools to solve the problem, but it's a little over engineered.
- cerved 4y agoThe problem you describe is how to interface with Google chrome on osx using shell script. I fail to see a single bashism.
- Jensson 4y agoIt loops through the rows of a file in the last example. But yeah, the main reason this works is that this is a trivial bash script. The main help you got is not having to read the chrome command line docs.
- lossolo 4y agoI've been using it more and more at work, and it's already saved me hours by generating bash commands and simple scripts/servers that I would otherwise have to search for on Google and adjust to my specific use case from multiple sources. Thanks to this tool, I have more time to focus on difficult and business-related problems. If they start charging for it, I will definitely become a paying customer. This is an excellent tool that is making me more productive, and I was a big skeptic about how LLMs work internally. Remove hallucination problem, add annotations with links to sources and this is how Google will look like in a few years. IMO this is how future of knowledge search will look like on the internet.
- ikealampe200 4y agoJust today I used ChatGPT to help me speed up writing somewhat trivial C Code for a project in an embedded systems class. Prompt: "Generate a tiny PID controller with only a Proportional factor written in C. That takes a rotational input from -360 to 360 degrees. The setpoint in degrees. And returns a motor speed in the range of -255 to 255." => Produced a compiling correct result. Later I wanted to know how to communicate between my kernel module and user space program: Prompt: "How do I get a value via character device from my kernel module into my user space c programm?" gave a bunch of answers and digging deeper with Prompt: "Could you provide me with an example of the user space program" gave a compiling and correct answer again. I could have written all of that myself while spending a good amount researching on google. But this way I felt less frustrated and was definitively a lot quicker. Not the solution for everything but maybe for a C beginner where research can take a long time and often leads to more confusion than anything else. Now the question is if that confusion is critical in the learning process. And if so how critical and at what stages of the experience spectrum the most?
- Panzer04 4y agoI guess the main concern with its use as a learning tool is what happens if it's wrong? It might be helpful for boilerplate when you already know what you want, but if you don't even know that it'll blow up in your face when it doesn't give you something workable. Still, seems like a viable assistant so long as you have an understanding of what you're working with.
- BlargMcLarg 4y agoIt's basically an augmenting tool. Can't rely on it 100% without a check, can't just do it without a vague idea of what the code does. As a combined boilerplate + search assistant it takes crazy amounts of work away as long as your specs are well defined, though.
- layer8 4y agoIt basically gives you suggestions of what could be correct, or close to correct, but yes you have to verify yourself, and possibly make some adjustments.
- an_aparallel 4y agoi will take a chance anywhere i can to just say it's a crying shame how useful this is - but also how crap it is that it requires use to be linked to your identity...
- secondcoming 4y agoWe're all doomed. This is going to ruin everything. Everyone's job will turn into debugging AI generated code.
- intelVISA 4y agoDepending on your team that might be an upgrade for some.
- bulldog13 4y agoCan anyone recommend some more articles about this ? Specifically, using chatgpt to write code? The more in depth, the better.
- nilsbunger 4y agoAsk ChatGPT! It can write one for you :)
- mbil 4y agoNot ChatGPT, but this article[0] (which was on HN earlier this year[1]) goes through building a small game in JS using OpenAI Codex. [0]: https://www.shawnmatthewcrawford.com/balloons-the-balloon-clicker-game.html https://www.shawnmatthewcrawford.com/balloons-the-balloon-cl... [1]: https://news.ycombinator.com/item?id=31211280 https://news.ycombinator.com/item?id=31211280
- hmsimha 4y agoThis isn't an article, but I used ChatGPT to make a Hacker News extension (which I'm now using), that highlights new comments when I navigate to a thread I've already visited: https://github.com/HartS/gpt-hacker-news-extension https://github.com/HartS/gpt-hacker-news-extension Each commit here contains my prompt in the commit message, and the changed code was entirely provided by ChatGPT. I also appended its output (including explanations) verbatim to the gpt-output file in each commit. So with each commit, you can see what I prompted it (the commit message), what it responded with (the change in the commit to that log file), and the code that I changed as a result of its response (all other changes in the repo). In actual use of the extension (if you want to use it), I changed the "yellow" background-color to "rgba(128,255,128,0.3)" (a light green color), but I did that change myself because I didn't think I'd be able to get it to pick a colour that looks good for HN
- bulldog13 4y agoWow man, this is amazing, thank you for responding!
- fariszr 4y agoAm I the only who think this is incredible!? If you would've told me a year ago when we would have an ai that can code based on normal human language prompts, I would've said maybe in 2025 or 2026, but its 2022 and it already exists! Man, if this what we have now, imagine what we will have in 2025 or 2030! I just hope this doesn't end up killing search engines and personal blogs, since no one needs to search for anything anymore. Also Ai generated replys are definitely an Extinction level threat for forums and the independent internet in general, let's hope OpenAI can find a way to make chatgpt replies easy to filter out.
- aksss 4y agoThis is a tool that I think openai originally made and seems to give you a probability that a sample block of text was or was not generated by openai. I pasted some of my own writing in there and said definitely not AI-generated. At this point, I don't know if I should be insulted by that or not. ;D https://huggingface.co/openai-detector https://huggingface.co/openai-detector
- roywiggins 4y agoSeems to have an issue with false positives: https://wandering.shop/@janellecshane/109464780848248093 https://wandering.shop/@janellecshane/109464780848248093
- fernly 4y ago502 bad gateway. Followed a link to the wayback machine but that page didn't do anything.
- aksss 4y agoStill works for me.
- layer8 4y agoIn the current state, everything the AI knows is stuff that people have written on the internet. It doesn’t seem to come up with new insights or judgements on its own. If people stop writing, AI won’t learn anything new (unless you turn it into AlphaZero for $DEVTOPIC). ChatGPT certainly saves time, but it becomes useless roughly at the same point where I would remain stuck after exhausting what Google Search turns up. That is, knowledge or conceptual topics that are hard to find on the web. At least for technical topics, ChatGPT doesn’t expand the scope of what you can find out without it, it merely speeds up the process.
- sureglymop 4y agoSince when is back awful to write? I live writing bash :(
- ramoz 4y agoWow, yea, I've have the exact same experience with bash. "im using mac, not linux" is an often prompt I need to use, but otherwise this type of flow works great for simple bash functions. For more advanced scripts, prompting & careful flow are important, but I've done some pretty awesome things. Today, ChatGPT helped me create a bash script to create a flat structure of large tars from an nTiB dataset directory by aggregating multiple sub-datasets & their files into the desired tar file size. Eg. "need single tar files of all the data in that folder/subfolder, every tar file must be 50GB, most files range from 4MB-1GB. So, need to aggregate them"
- solarkraft 4y ago> But it fucking sucks. Like, it’s truly awful to write I feel like I'm the only person among my peers to think this and I don't understand why.
- LelouBil 4y agoI had to try PowerShell for a project. It is soooo much better that bash. Passing typed objects instead of only text, Typed functions, and the ability to use C# types/functions inline !
- solarkraft 4y agoTo me it's about half way there. The things I like about it the least are the ones that are like bash ("I'd just like to interject for a moment, what you're referring to as Bash is in fact called POSIX shell"). A common argument in defense of its weirdness is that "shell scripting isn't like serious software development", but I don't understand that either. I use shell scripts a good amount because "it's right there" is a strong argument, but in a lot of cases things that seem like they would be trivial take forever, are horribly hacky and leave me wishing I just had written a Python script right away instead. I really don't get why people like shell scripts.
- throwaway747271 4y agoPeople like shell scripts because you have one interface: text For example: you need to write an image to a USB stick. Python: pretty lengthy BASH: image > /dev/SDA Both will do exactly the same, but one is a few lines of python the other just one line in bash.
- hn92726819 4y agoWhy a throwaway for this? Is this a gpt response? Also it's not right. You need to do something like image.img <cat> /dev/sda
- 4y ago
- _jayhack_ 4y agoTry LLM.sh - GPT-3 in your terminal https://github.com/jayhack/llm.sh https://github.com/jayhack/llm.sh Type `llm [natural language command]` and it will suggest a command for you, then run it. Details here: https://twitter.com/mathemagic1an/status/1590480438258462721 https://twitter.com/mathemagic1an/status/1590480438258462721
- xlii 4y agoOn the other hand I’ve had vastly different experience. Every single time I went to GPT and ask for anything development related I came back empty handed after being send for the goose chase. An example of this would be when I asked fswatch to emit one faux event preemptively and it insisted to use “-1” instead (which quits after one event). I had few instances for more obscure problems where GPT would actually create something I’d call parallel universe of the API. It felt good but such API never existed. Those problems were in JS, Ruby, Shellscript and Elixir. One of the worst answer I was given was actually really buggy implementation of input controlled debounce function. It seemed correct when running but in reality it wasn’t debouncing but ignoring the output on debounce call. So yeah, I don’t think I’ll be using GPT for that soon, but it works quite well as a rubber duck equivalent. By proposing dumb solutions I gather my thoughts better. Not sure if that’s something I’d pay for (yet I’d pay for text generating capabilities) Edit: denounce -> debounce, because autocorrect
- aaron695 4y ago[dead]
- albert_e 4y agoI am very excited to see this being integrated with a lot of productivity tools -- removing the need for manually copy-pasting the ChatGPT output into various other apps like VS Code or Excel :) "Create a new Python project folder named 'hello-openapi' and initate a git repo. Create a requirements.txt with openai, os and json. Create a starter python file with an openai example code and make the first commit."
- deleted 4y ago[deleted]
- timwis 4y agoI’ve been waiting for ChatGPT to be “available” for weeks now (it was too busy before). How have so many people been able to use it?