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: Dave Woodfall
Subject: Re: Help using eval in screenrc
Date: Sun, 29 Mar 2020 07:51:13 +0100

On 2020-03-28 16:20,
dan d. <address@hidden> put forth the proposition:
>
> I recently asked how one can stack commands with one keybinding in screenrc
>
> One poster pointed me to eval, which is surely the solution.  Much googling 
> for examples confirmed it can work.
>
> But alas I have had no joy trying to modify the examples for my purpose with 
> multiple trial and errow attempts.
> 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.
> --
> Has anyone experience/suggestions for this?

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.

Hope this helps.



reply via email to

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