I often use more than one terminal (or terminal emulator) at a time; and while in X I can copy-paste commands, besides not being very practical, it obviously does not work on the real TTY. The first idea that occurs to me is something alike:
command > /dev/sometty
Unfortunately, the command
is run before it is piped, and no tricks like echo `command`
will work, no matter how many weird bash characters ($
, `
, "
, etc.) are there. So /dev/sometty
simply gets some text.
The problem is that, sometimes, it is even worth for I to pipe those commands into a file, make it executable, etc., or shortly: making a script and running it from the appropriate terminal. But that is a lot of work. I've been thinking of making a script to make these files, for an instruction:
termpipe -e "command1\ncommand2\"command 1 argument\\n(s)\"" -t /dev/sometty
it would do something like:
- pipe the commands to, say,
/tmp/termpipe-20140208-153029-1.sh
- make the file executable
- run the file in the appropriate terminal
- delete the script when it is done executing
AFAIK, the problem is in 3.: this doesn't solve any problem, as I'd need another termpipe
instance to run the first on the appropriate terminal. And one for that one. And another for that, ad infinitum. So this cannot work. Or can it?...
The solution could be to use a named pipe per terminal, and when each starts, a script would tell the pipe to forward anything it receives to the terminal, and then to execute it (like a sort of daemon).
I think this might work but I don't know how to set up the initial script. How can I? How can I tell the FIFO to give piped commands for the respective terminal to run? I don't know much Bash, so I'd appreciate full explanations.
screen
ortmux
(which have keyboard based copy pasting). On Linux, you can also use gpm to do copy-pasting with the mouse. – Stéphane Chazelas Feb 08 '14 at 16:51tmux
could do that. But isn't there any way for what I suggested work? – JMCF125 Feb 08 '14 at 17:35cron
... But that's another question... – JMCF125 Feb 08 '14 at 19:31command > /dev/sometty
to becommand | tee /dev/sometty
isn't that|
an unnamed pipe? Sorry if this is an innapropriate name, it's what I've always heard. – JMCF125 Feb 08 '14 at 22:13|
creates a pipe.>
doesn't. And even if I interpret “redirection” when you wrote “pipe”, I have no idea what you're asking:command >/dev/sometty
does redirect the output of the command to another terminal. – Gilles 'SO- stop being evil' Feb 08 '14 at 22:28echo "command" > tty3pipe
(after the scripting before), withcommand > /dev/tty3
. How can I make this clearer? (note: this is not a void question, it's real asking for improvement; if an expert doesn't understand my question, then there's something wrong with the way I wrote it) – JMCF125 Feb 08 '14 at 22:41command </dev/tty3 >/dev/tty3 2>/dev/tty3
? (If this dialog gets any longer, please consider continuing in chat.) – Gilles 'SO- stop being evil' Feb 08 '14 at 22:55>
and<
) Thanks! But that does do the same as what I got below, only with colours by default, unlike my solution. Why is that? May you post an answer please? – JMCF125 Feb 08 '14 at 23:02/dev/tty3
for input, output, and error messages, right? I can put that as an answer, but I don't want to steal your idea. Maybe one could make a script to avoid writing/dev/tty3
thrice. In fact, consider it done. – JMCF125 Feb 09 '14 at 11:21/dev/tty3
, and you run another program getting input from/dev/tty3
, they will compete for input). – Gilles 'SO- stop being evil' Feb 09 '14 at 11:58/dev/tty3
. An example use would be: I find a long command in the internet that does what I want. I was already on the directory I am supposed to be to run the command in/dev/tty3
. But I can't copy it to there. Sure, I can dopwd > /dev/pts/0
, but I'll have to copy the directory name andcd
there before I copy the other command. Giving the command for/dev/tty3
to take care of is just easier. – JMCF125 Feb 09 '14 at 12:05sed
, I got my solution below automatized! Withoutcron
! I will post it ASAP. – JMCF125 Feb 09 '14 at 16:30