News for hackers. Stuff that matters.
Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @07:03AM (#35840150)
I made a script that uses atuin to get previous commands related to your current command line - latest commands ran in the same session, in the same directory, in other sessions, latest commands for the same executable etc. then feeds it into GPT and streams the replies to fzf so you can choose the best autocompletion (or it can fix problems in the line you've written already as well). On Wezterm and Kitty it can also get the terminal screen contents error messages and so. Because of the streaming reply the first autocomplete line is ready quite soon after the keyboard shortcut is pressed.

Have been putting off pushing it to Github, think I'm gonna do that today.

Re:Atuin replaces your existing shell history with a SQLite ... by conradludgate on Saturday May 06, 2023 @07:14AM (#35840203)
That sounds awesome! We've been meaning to set up a "community showcase" section. I'd love to feature this! If you ever publish it, post a discussion!
Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @01:36PM (#35843535)
Thanks! I'll do that after I've had more time to finish some features and clean the code up in few days. But I've released a crude version at https://github.com/TIAcode/LLMShellAutoComplete
Re:Atuin replaces your existing shell history with a SQLite ... by mkurz on Saturday May 06, 2023 @07:05AM (#35840159)
Please link, thanks!
Re:Atuin replaces your existing shell history with a SQLite ... by literalAardvark on Saturday May 06, 2023 @09:37AM (#35841234)
That sounds awesome, if somewhat overengineered.

Though the idea of mistakenly putting credentials in the cli and it ending up in GPT is bothering me a bit.

Re:Atuin replaces your existing shell history with a SQLite ... by doubled112 on Saturday May 06, 2023 @12:03PM (#35842646)
Probably paranoia, but I’d be uncomfortable feeding it a bunch of domain and server names, along with any other more interesting params that might sneak in.
Re:Atuin replaces your existing shell history with a SQLite ... by miller_joe on Saturday May 06, 2023 @10:12AM (#35841585)
I’ve been using atuin for a while and have been thinking about something like this. Please do post to GitHub!
Re:Atuin replaces your existing shell history with a SQLite ... by chefandy on Saturday May 06, 2023 @10:41AM (#35841824)
Does it incorporate the return code of the commands to get an approximate good/bad rating? I wonder what percentage of the CLI mistakes I make return zero anyway because it's a valid command that I simply misused.
Re:Atuin replaces your existing shell history with a SQLite ... by codetrotter on Saturday May 06, 2023 @11:49AM (#35842512)
For me one of the most common issues is when I write a regex but I have some of the escapes the wrong way around etc. So I’m giving a valid regex, but it’s not matching what I tried to match. And then I have to change it around a couple of times before it works.

One reason for this is that different programs have different rules for what should be escaped when, when you write a regex. For example, I think grep is a bit different from vim in this regard

Re:Atuin replaces your existing shell history with a SQLite ... by chefandy on Saturday May 06, 2023 @01:21PM (#35843393)
Hm... Now that I think about it, regex tools on the command line haven't been a goto recently. I used sed, awk, perl -e, et. al. constantly from the late 90s until maybe 2015 but since then I'm more likely to pop open a ipython repl or whatever and avoid those weird inconsistencies altogether. Also, developing on the old scp->LAMP stack setup required more shell script glue than the more automated contemporary setups I've been using.

I'd probably suck at it. No matter how frequently I use regex in :ex commands, I always screw up the escapes, substitutions, etc.

Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @02:24PM (#35843962)
It doesn't, I think it should but not sure how to add it to the prompt yet - I have a feeling that if I'll just add them after or before the command line, GPT will at least occasionally add hallucinated return codes to the autocompletion. Maybe I'll just add the unsuccessful codes or something, but it needs some testing.
Re:Atuin replaces your existing shell history with a SQLite ... by chefandy on Saturday May 06, 2023 @02:32PM (#35844038)
Cool. Neat tool idea.
Re:Atuin replaces your existing shell history with a SQLite ... by alfons_foobar on Saturday May 06, 2023 @10:51AM (#35841912)
Isn't that like... ultra slow?
Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @01:20PM (#35843386)
It's usually ~two seconds or so for the first line to come out of OpenAI. You can see the example video in the github, though I think that was little slow.

If you have big atuin file though, creating indexes for session and cwd are good ideas so we can get the request out quickly..

edit: but much faster than searching or asking LLM for command line parameters instead

Re:Atuin replaces your existing shell history with a SQLite ... by killthebuddha on Saturday May 06, 2023 @02:57PM (#35844309)
Copilot is highly usable and I'm pretty sure it works the same way.
Re:Atuin replaces your existing shell history with a SQLite ... by Shakahs on Saturday May 06, 2023 @07:44PM (#35846446)
Copilot also runs a small model on the users machine to quickly provide simple predictions.
Re:Atuin replaces your existing shell history with a SQLite ... by killthebuddha on Saturday May 06, 2023 @09:08PM (#35846877)
Interesting, I didn’t know that.
Re:Atuin replaces your existing shell history with a SQLite ... by samstave on Saturday May 06, 2023 @12:15PM (#35842738)
>"...then feeds it into GPT..."

explain this please

Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @01:56PM (#35843723)
It feeds the information from atuin database as a prompt for OpenAI, like: "Latest calls for the same executable:\ncmd1\ncmd2" (I should work on my prompts, doesn't actually look that optimal, oh well). Then at the end gives the current command line and asks for few options how to finish / replace the line, with some extra requests for GPT (like don't write anything else except the command line etc).
Re:Atuin replaces your existing shell history with a SQLite ... by bayesianbot on Saturday May 06, 2023 @12:50PM (#35843075)
Well it's published. Wasn't ready to publish and didn't have time to clean it up but I'll get back to it in the coming days, there's also some extra features on the way but disabled currently. Works quite well for me though.

https://github.com/TIAcode/LLMShellAutoComplete

Forgot to add needs tiktoken, openai and fzf. If someone knows how to do that command line query and replace on other than fish/nushell, please let me know.