You are not logged in.

#1 2012-04-02 19:25:45

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

urxvt help - how to run a command in the same urxvt instance

I want a bash script to run makepkg inside a dedicated urxvt window.  I can do this as follows:

urxvt --geometry 100x30 -e bash -c "makepkg -src"

The problem is that the above command is being calling inside a for loop.  Each time this code is called, makepkg runs BUT it runs in a different instance of urxvt.  I want each subsequent instance of makepkg to run in the same urxvt window.  I think the --hold switch might help here but I do not know how I can direct each loop into the same window.

Thanks in advance.

Offline

#2 2012-04-02 19:50:40

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: urxvt help - how to run a command in the same urxvt instance

If I understand you correctly, you may run urxvt as a daemon and launch urxvtc instead.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#3 2012-04-02 22:07:40

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: urxvt help - how to run a command in the same urxvt instance

I don't think -hold would do what you want, as it only keep the window open after the program execution, but (I don't think) you can re-use that window with another program.

Any reason you can't just do `makepkg -src` instead, and run your bash script containing the loop with `urxvt --geometry 100x30 -e foobar` ? That way all output should be in the same window.

Offline

#4 2012-04-03 09:20:23

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: urxvt help - how to run a command in the same urxvt instance

I've never done this, but  as I understand them, you could use a named pipe (FIFO). You would set up the pipe and new terminal window outside the loop, and have the script in the new terminal window listening on the pipe, then in the loop send the commands - or the dirs/files/etc on which the commands will act - to the pipe for processing.

EDIT: or you might be able to use something like xdotool or similar to send the commands to the window. Again, I've never tried running commands at the prompt with x automation tools, but it might be possible with one of them.

Last edited by skanky (2012-04-03 09:24:05)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#5 2012-04-03 11:13:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: urxvt help - how to run a command in the same urxvt instance

I'd second bohoomil's suggestion as the simplest if it could work.  You wouldn't necessarily need another script file though.  The following wiill run:

#!/bin/bash

urxvtc -e bash -c "
echo hello
echo world
read line
"

The echos could be changed to makepkg commands.  The read line is only there so the window sticks around long enough to see the output.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2012-04-03 12:09:33

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: urxvt help - how to run a command in the same urxvt instance

Based on Trilby's script, you could build a list of commands with the loop, and pass them to the window as a parameter to eval:

$CMDS="echo hello;echo world;read"
$urxvtc -e bash -c "eval $CMDS"

"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

Board footer

Powered by FluxBB