5 ms·
My current secrets: * cht.sh is a great way to avoid a lot of this stuff - there's a commandline tool as well * usable cli ai setup: simonw's llm (https:
by kristopolous 2y ago
My current secrets:
* cht.sh is a great way to avoid a lot of this stuff - there's a commandline tool as well
* usable cli ai setup:
simonw's llm (https://github.com/simonw/llm https://github.com/simonw/llm)
+ openrouter (https://github.com/simonw/llm-openrouter https://github.com/simonw/llm-openrouter)
+ free models (https://openrouter.ai/models?max_price=0 https://openrouter.ai/models?max_price=0)
+ glow (https://github.com/charmbracelet/glow https://github.com/charmbracelet/glow)
+ adding this to your .rc file:
function lm {
local input="$*"
llm -s 'Answer as short and concise as possible' ${input} | glow
}
Here's an example,
$ lm "ssh command to forward the port 5050 on user@remote to my localhost:7001"
ssh -L 7001:localhost:5050 user@remote
$
Now for a sophisticated use-case I have a small tmux program where I can capture what's on the pane, enter a prompt and it will query an llm so I can say things like "How do I fix this error" or "what debian package do I need to get this to run right?" ... both these are recent patterns I've started and they've been real game changers
Some lesser game-changers:
* tmux extrakto - opens an "fzf" like search of all the text on the screen. So after a "git status", I can do git add (run extracto - enter partial path, press tab) and continue: https://github.com/laktak/extrakto https://github.com/laktak/extrakto
* mcfly history: https://github.com/cantino/mcfly https://github.com/cantino/mcfly just watch the demo, you'll see
* ugrep: grep with a powerful tui: https://github.com/Genivia/ugrep https://github.com/Genivia/ugrep - I became an instant convert.
* batcat: https://github.com/sharkdp/bat https://github.com/sharkdp/bat ... you really need to use some of its other features to leverage it. It's really nice.
- regnull 2y agoI did a similar thing, where you describe what you want to achieve and it gives you the command and (optionally) executes it for you: https://github.com/regnull/how.sh https://github.com/regnull/how.sh
- kristopolous 2y agoI see you did some prompt engineering: https://github.com/regnull/how.sh/blob/main/how.sh https://github.com/regnull/how.sh/blob/main/how.sh I think the real sweet-spot flow is to take this and use bindkey to do inline replacement. Let me fork it and see what I can do.
- regnull 2y agoYeah I tweaked the prompt to make it work reasonably well. There is also an experimental mode where it can reason and correct the command if it fails. Feel free to sent a PR!
- kristopolous 2y agoAlright, done. It's a re-invention really. Essentially you do (assuming zsh) $ source how.sh Then you type your thing at the shell $ add a user bob using modern homectl methods Then you (in the default, CTRL+X+H) and it does this $ add a user bob using modern homectl methods ... (name of your default model) ... a few seconds pass ... $ sudo homectl create-user bob Then you can choose to press enter and run it. https://github.com/kristopolous/how.sh https://github.com/kristopolous/how.sh This is a much more one-and-done approach but 99% of the time I just forget invocation syntax - I'm not actually exploring things deeply. If you want a "proper" pr, it'd really be a rewrite with two "frontends" - your conversational edit flow and my keystroke invoke. Honestly they're probably different things.
- regnull 2y agoInteresting approach, thanks for sharing!
- ddworken 2y agoI actually made a CLI tool (https://github.com/ddworken/hishtory https://github.com/ddworken/hishtory) that automatically binds to Control+R to support both history searching and AI queries (by prefixing queries with `?`). Here's the prompt engineering I did: https://github.com/ddworken/hishtory/blob/master/shared/ai/ai.go#L149-L152 https://github.com/ddworken/hishtory/blob/master/shared/ai/a...
- kristopolous 2y agoAh this is a far more significant effort. I'm glad to see that there's so much consensus that default shell history is broken (I used to use logrotate because it would always truncate regardless of how many ways I told it to not ever, under no conditions, ever, do that). Nice to see there's so many options these days. Someone else mentioned "https://atuin.sh/ https://atuin.sh/" in this thread - which is also new to me. Keeping up with things is seemingly impossible
- scottyeager 2y agoHere's my take on an LLM based shell helper for command suggestions and more: https://github.com/scottyeager/Pal https://github.com/scottyeager/Pal It features an integration with the abbreviation feature in fish and zsh (via plugin) to expand the suggestions for editing, if needed, and execution. There's stdin support, which can be used to pipe in error messages, for example. I've thought about something like your tmux setup to capture and pass some history to the model, but in practice redirecting stderr handles most of the potential use case.
- thwarted 2y ago> Here's an example, $ lm "ssh command to forward the port 5050 on user@remote to my localhost:7001" ssh -L 7001:localhost:5050 user@remote Was this a real example of the input and output generated, because it seems wrong. -L 7001:localhost:5050 listens on port 7001 locally and forwards connections to 5050 on the remote host. Based on the request, you want -R 5050:localhost:7001, which listens on port 5050 at the remote end and forwards connections to a server listening on localhost:7001 on the local end.