Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been saving a lot of time in the terminal recently with shell-gpt (https://github.com/tbckr/sgpt):

    $ sgpt -s "The command 'sp current' outputs
    > Album        Tea For The Tillerman (Remastered 2020)
    > AlbumArtist  Yusuf / Cat Stevens
    > Artist       Yusuf / Cat Stevens
    > Title        Wild World
    > I want just 'Wild World by Yusuf/Cat Stevens'"

    sp current | awk -F'  +' '/Title/{title=$2} /Artist/{artist=$2} END{print title " by " artist}'
    [E]xecute, [D]escribe, [A]bort: A
    E

    Wild World by Yusuf / Cat Stevens
Looking back at it, the awk command it uses is actually pretty clean.


It should use ^Title and ^Artist, otherwise something with "Artist" or "Title" will give wonky results.

More importantly, you can get the same results by just one or two dbus-send commands instead of using that "sp" script + something to clean it up.

The sp-metadata function uses tons of processes to clean the output[1], and sp-current launches a few more. If you're doing this in a loop for your WM status display this sort of stuff really adds up. Even on modern systems launching processes isn't free and relatively slow, and launching >20 of them every few seconds is going to use non-trivial amounts of CPU and will needlessly drain your battery.

I don't really know what that dbus command outputs, but I bet that with you might go a long way with "dbus-send ... | grep -o ..." or something.

So in general I'd say this is a classic case of "you're not even using the right solution, and no amount of GPT is going to help".

[1]: https://gist.github.com/streetturtle/fa6258f3ff7b17747ee3#fi...


The "^Title and ^Artist" is a good point.

The "sp current" issue seems less fair to bring up, as the entire article was using that throughout as well.


That's really awesome!

Shell scripting is the perfect use case for ChatGPT. Simple enough that AI can handle it, annoying enough that I don't really want to do it myself, and something I do rarely enough that I don't really know any of the commands deeply.


Very cool! It reminds me of Microsoft Prose[1]. I guess they were way ahead of their time on that one.

[1]https://www.microsoft.com/en-us/research/group/prose/


That's a nice tool, I'll have to try it.

Out of curiosity I asked bog-standard web ChatGPT (4) if it could do the job in awk, took it five times to get it right. Whatever prompt shell-gpt is using, it works.


That's terrifying. How do you guarantee this (or its user) doesn't end up running `sed -i`?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: