Live data from Hacker News

Using ChatGPT to make Bash palatable

brev.dev

101–110 of 148 posts

Re: Using ChatGPT to make Bash palatable

#101

Can anyone recommend some more articles about this ? Specifically, using chatgpt to write code? The more in depth, the better.

This 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

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

Re: Using ChatGPT to make Bash palatable

#102
post #87

Earlier quoted context omitted.

I 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.

It 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.

And honestly that's already amazingly valuable and I've been using it constantly for weeks because it narrows your search space through the documentation to the head of a pin.

Hey I need to process the EXIF data for an image; let's Google "pillow exif" and see what we get.

https://pillow.readthedocs.io/en/stable/reference/ExifTags.h...

Uhh, okay. Kinda? Maybe? This doesn't actually tell me how to actually get that data from a real image.

> Write a python program using pillow to print all the EXIF data for an image in a human readable way

    from PIL import Image
    from PIL.ExifTags import TAGS 

    # Create an Image object 
    img = Image.open('image.jpg') 

    # Get EXIF data
    exif_data = img._getexif() 
 
    # Iterate over all EXIF data fields
    for tag_id in exif_data: 
 
        # Get the tag name, instead of human unreadable tag id
        tag = TAGS.get(tag_id, tag_id) 
 
        data = exif_data.get(tag_id) 
 
        # Decode bytes 
        if isinstance(data, bytes): 
            data = data.decode() 
 
        print(f"{tag:25}: {data}")
Is it correct, sorta, close though. But it tells me I should look for a method on the image object called getexif -- hey it exists, nice! And that's what TAGS is for! Makes way more sense.

Re: Using ChatGPT to make Bash palatable

#103
post #72

Earlier quoted context omitted.

Is there a reason you can't add a script to your path and alias that? #!/usr/bin/env bash my-command --flag --another-flag $@

As 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.

You 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.

Re: Using ChatGPT to make Bash palatable

#104
post #79
post #59

Am 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 anyt…

This 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

502 bad gateway. Followed a link to the wayback machine but that page didn't do anything.

Re: Using ChatGPT to make Bash palatable

#105

Earlier quoted context omitted.

I 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 !

To 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"…

People 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.

Re: Using ChatGPT to make Bash palatable

#107
post #81

Earlier quoted context omitted.

> Bash _itself_ (or any other shell) is very small. You're talking about the ecosystem (shell + other command line utilities). I'm not so sure. They mentioned syntax, and the single biggest issue among my co-workers who don't like bash is that they think ' and " work like they do in python or javascript.

They mentioned "20 ways of doing things", I'm replying to that complaint. Quoting is an issue if you don't understand the IFS and command expansion. It's an old fashioned style, but it is consistent and there's only one way of doing it (quoting every variable and subshell use). Think of shell variables as non first-class citizens, they can only be used interpolated within a string, like "$var". The shellcheck tool en…

To give a more solid example, they don't understand why

  npm test
works and why they don't need

  npm "test"

Re: Using ChatGPT to make Bash palatable

#108

Earlier quoted context omitted.

I 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…

While 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…

I really need to read Chomsky. I agree with your point!

Re: Using ChatGPT to make Bash palatable

#109

Earlier quoted context omitted.

To 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"…

People 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.

Why a throwaway for this? Is this a gpt response?

Also it's not right. You need to do something like image.img /dev/sda

Re: Using ChatGPT to make Bash palatable

#110
post #84
post #59

Am 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 anyt…

In 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 u…

One avenue that chatGPT has, and I'm not sure if it is being utilized at all yet, would be the ability to feed it the unimaginably huge body of information locked behind copyrighted textbooks, books, academic papers and other pay walled information.

Imagine the knowledge that could be accessed by feeding all that information into an ai engine like chat gpt. Presumably, it would not break copyright rules anymore than a regular human reading a bunch of papers behind a paywall and regurgitating the learned information.

Post reply on HN