ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Thanks.
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.
Last edited by sidlover; 11-13-2008 at 04:34 PM.
Reason: clarification
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.