Input Text into a Command-Line Argument from an Editor
The convienient open source editor Micro has a nice feature which allows it to easily create buffers from stdin, and send the data of the open buffer to the pipe when it exits.
For example: ifconfig | micro | cat
Similarly, you can use Micro in a subprocess to “inject” text into a CLI command. E.g. with Llama.cpp:
This will start the Micro editor, where you can enter (potentially large amounts of) formatted text for use as the LLM’s prompt, without needing to save to a file or make a temporary file.
It works well in scripts:
and it also only stores “$(micro)” in your command history, which avoids long input clutter.
Opening a file in the editor
While opening a file inside Micro after-the-fact doesn’t appear to correctly pass the information back to the CLI, you can start with a file quite easily with:
This will start the editor with the file open, and pass any changes back to the command-line on exit without modifying the original file.