Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TIAcode/LLMShellAutoComplete
Use GPT to complete shell command line using atuin shell history database and terminal screen content as prompt
https://github.com/TIAcode/LLMShellAutoComplete
atuin autocomplete gpt shell
Last synced: about 1 month ago
JSON representation
Use GPT to complete shell command line using atuin shell history database and terminal screen content as prompt
- Host: GitHub
- URL: https://github.com/TIAcode/LLMShellAutoComplete
- Owner: TIAcode
- Created: 2023-05-06T16:40:45.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-06T17:45:15.000Z (over 1 year ago)
- Last Synced: 2024-07-10T07:51:05.382Z (2 months ago)
- Topics: atuin, autocomplete, gpt, shell
- Language: Python
- Homepage:
- Size: 135 KB
- Stars: 103
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChatGPT autocompletion with atuin
Autocomplete using GPT, using data from [atuin](https://github.com/ellie/atuin) command history as input prompt. Uses streaming responses to get the first reply really quickly
The README is put together in minutes, I fill fix it soon.![GPT completer in use](gptcomplete.gif)
## Usage
## Python requirements
`pip install --user tiktoken openai` should be enough, or you can do venv for them and point the shell configurations to the correct Python.## Other
[fzf](https://github.com/junegunn/fzf) for selecting the correct result.### Nushell
Add this to config.nu:
```
{
name: complete_with_gtp
modifier: CONTROL
keycode: Char_o
mode: [emacs vi_normal vi_insert]
event:[
{ send: executehostcommand,
cmd: "commandline -r (python /path/to/completer.py (commandline) | fzf --track --height 8)"
}
{ send: Enter }
]
}
```### Fish
To config.fish:```
function gpt_completion
commandline (python /path/to/completer.py (commandline) | fzf --track --height 8)
end
bind \ck "gpt_completion"
```### Other parameters
`--atuin`: atuin history database location`--dunst`: Use dunstify to notify what's happening (debug mostly)
`--model`: gpt-3.5-turbo or gpt-4. GPT-4 feels much slower for me for this use.
`--wezterm`: Append screen content from Wezterm
### Atuin indexes
This makes a few queries from atuin database so few more indexes can speed it up quite a lot:
```
sqlite3 ~/.local/share/atuin/history.db
CREATE INDEX idx_history_cwd on history(cwd);
CREATE INDEX idx_history_session on history(session);
```### Terminal content (Wezterm/Kitty)
If you're using [Wezterm](https://github.com/wez/wezterm) you can also add your current terminal screen content to the GPT prompt, which might be useful if there's some error messages that could help generating the correct command line. In that case add -w for the completer.py command line.Kitty get-text is commented in the code as I couldn't get it working right now, I'll fix it soon or let me know if you find a way.
## Disclaimer
This was posted quite hastily as Atuin hit the HN front page. Code is terrible, there's a bunch of half ready features commented out and I haven't tested it too much. Might require some fixes to work well elsewhere. I'll have a look in the coming days to clean it up.