-   Programming (
-   -   CLI editor scripting paste (

sidlover 11-13-2008 03:12 PM

CLI editor scripting paste
Hi everyone,
I'm getting confortable scripting in bash and I have a quastion:

Is it possible to programmatically paste some text into a running CLI editor using bash?

I've binded a key in GNUScreen to run a script that hopefully would paste (send) text into my editor (nano).
I can 'echo' text into my running editor, and I actually see the text, but the editor doesn't retain it when I save the file. I suspect it has nothing to do with the editor per se. Is there a way to do it?

I'm currently working on a workaround by sending the text to the file directly, then close-reopen nano, but am curious if it can be done on the fly.

irishbitte 11-13-2008 03:45 PM

Using 'nano' the paste command is:


sidlover 11-13-2008 04:29 PM

Hi irishbitte.
I want bash to do it for me (from a GNUscreen binding). That way any text could be 'inserted' (better term) from the clipboard or elsewhere in my running nano session.

jlinkels 11-14-2008 04:39 PM

You should perhaps realize how it is possible to paste text into a window. I am talking about a console window, that is a CLI running inside a window initiated from a GUI.

If you copy text from somewhere, and paste it into the console, the GUI environment knows that the paste command involves simulating keypresses into that console. Your CLI application is totally unaware that something is pasted, it just sees the keystrokes being generated by the paste command.

So if you want to paste something in a CLI environment, NOT running in a GUI window, you have to be sure that the CLI application KNOWS what it is to get something pasted. Usually that is pretty much impossible.


All times are GMT -5. The time now is 10:16 PM.