7 ms·
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,
by bayesianbot 3y ago
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.
- mkurz 3y agoPlease link, thanks!
- conradludgate 3y agoThat 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!
- bayesianbot 3y agoThanks! 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 https://github.com/TIAcode/LLMShellAutoComplete
- literalAardvark 3y agoThat 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.
- doubled112 3y agoProbably 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.
- miller_joe 3y agoI’ve been using atuin for a while and have been thinking about something like this. Please do post to GitHub!
- chefandy 3y agoDoes 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.
- codetrotter 3y agoFor 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
- chefandy 3y agoHm... 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.
- bayesianbot 3y agoIt 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.
- chefandy 3y agoCool. Neat tool idea.
- alfons_foobar 3y agoIsn't that like... ultra slow?
- bayesianbot 3y agoIt'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
- killthebuddha 3y agoCopilot is highly usable and I'm pretty sure it works the same way.
- Shakahs 3y agoCopilot also runs a small model on the users machine to quickly provide simple predictions.
- killthebuddha 3y agoInteresting, I didn’t know that.
- samstave 3y ago>"...then feeds it into GPT..." explain this please
- bayesianbot 3y agoIt 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).
- bayesianbot 3y agoWell 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 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.