Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-13-2008, 04:12 PM   #1
LQ Newbie
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
Question 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.
Old 11-13-2008, 04:45 PM   #2
Senior Member
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 83
Using 'nano' the paste command is:

Old 11-13-2008, 05:29 PM   #3
LQ Newbie
Registered: Nov 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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 05:34 PM. Reason: clarification
Old 11-14-2008, 05:39 PM   #4
Senior Member
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,707

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
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.



bash, cli, nano, paste, scripting, text

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy/paste a line in nano editor smp0219 Linux - Newbie 7 01-03-2016 07:40 PM
record audio; auto-paste editor; desktop search ctos Slackware 2 03-17-2006 12:39 AM
Looking for the ultimate CLI id3v2 editor javeree Linux - Software 0 10-17-2005 07:21 AM
CLI copy & paste between text files? David the H. Linux - General 3 09-15-2004 01:05 PM
Editor to cut & paste into mozilla - Knoppix 3.4 suguru Linux - Software 2 05-12-2004 04:54 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:33 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration