screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help using eval in screenrc


From: dan d.
Subject: Re: Help using eval in screenrc
Date: Sun, 29 Mar 2020 16:24:49 -0400 (EDT)
User-agent: Alpine 2.22 (OSX 394 2020-01-19)

On Sun, 29 Mar 2020, Dave Woodfall wrote:

> On 2020-03-28 16:20,
> dan d. <address@hidden> put forth the proposition:
> >

> > I want to do a keybinding with eval to stack these commands which work now 
> > when entered manually:
> >
> > 1. enter the command c-a, defined for me as ^F.  I couldn't find in the 
> > examples if this a literal ^F or some
> > other representation of the command key.
> >
> > 2. do a "hardcopy entering h, one example suggests a -X hardcopy works, no 
> > joy. wen tried.
> >
> > 3.. Enter an already defined keybind with exec which runs a shell script 
> > manipulating the hardcopy text file.

> With eval you can use multiple screen commands (but sometimes with a
> caveat)
>
> Examples from my ~/.screenrc
>
> bind <key> eval 'resize -1' 'copy'
> bindkey -m <key> eval 'resize -1' 'copy'
>
> What they do is run the screen commands in single quotes as if I'd
> entered them by normal means one by one.
>
> resize -1 (resize a split -1 units)
> copy (enter copy mode, or in the 2nd example return to copy mode)
>
> So for your hardcopy example you would use something like:
>
> eval 'hardcopy' '2nd command' ... 'nth command'
>
> The caveats are where if you want to run some kind of external
> command or filter using 'exec' then you may find that the rest of the
> commands run without waiting for the exec to finish.
>
> In those cases you could use 'exec' to run a shell script and put all
> the commands in there as screen commands, possibly with sleep to help
> with timing:
>
> #!bin/sh
>
> screen -X hardcopy
> sleep 2
> screen -X ...
> etc
>
> Or with more than one screen session you may need to define the
> session with -S
>
> screen -S mysess -X hardcopy
> etc.

Thanks, exactly what I was trying to do.  I went with the exec with shell 
script version.

That allows me to quickly experiment with different things without redoing the 
screenrc each time, just redo the shell script and try it.
>
Next I'm looking into the stuff command to use a shell script to send commands 
to a currently running application,
that in effect could become a custom macro for any application.

-- 
XB



reply via email to

[Prev in Thread] Current Thread [Next in Thread]