On Sat, Mar 28, 2020 at 04:20:51PM -0400, dan d. wrote: > > 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? > > Many thanks. > > Dan > XB
First, I have my c-a key bound to c-^. I don't know who thought c-a was a reasonable choice since it's often used for the beginning of line in most shells I use. c-^ is unused by most everything that I have found. Add this line to your .screenrc to do this: escape ^^^^ I don't know if this will help but I created for myself a key which repainted the scrollback buffer. pastefont on defscrollback 2000 register A "\036[g G$>\000\036:exec /home/mgrant/bin/redraw-screen\015" bind ^l process A Some explanation of register A: \036 is the ctrl-^ character (which was ctrl-a before using the escape comm= and above) [ is the copy command (see https://www.gnu.org/software/screen/manual/html_= node/Copy.html#Copy) g moves to the beginning of the scrollback buffer (see https://www.gnu.org/= software/screen/manual/html_node/Movement.html#Movement) <space> sets the first line to be marked G moves to the end of the scrollback buffer $ writes the marked selection to /tmp/screen-exchange (see https://www.gnu.= org/software/screen/manual/html_node/Specials.html#Specials) \000 ends the command <---- THIS MAY ANSWER YOUR QUESTION \036 is the ctrl-^ again : introduces a command (see https://www.gnu.org/software/screen/manual/html= _node/Colon.html#Colon) exec (see https://www.gnu.org/software/screen/manual/html_node/Exec.html#Ex= ec) redraw-screen is this command below \015 is a newline which ends this whole sequence by entering the command In order to get all of that into a key, I put it in a register and bound a = key to process that register. Here is my redraw-screen command: #!/usr/bin/perl # Use sleep to create a delay so as not to overrun Screen use Time::HiRes qw(usleep nanosleep); # expects screen dump to already be in /tmp/screen-exchange # from the '>' write screen-exchange command in screen open(FP,"</tmp/screen-exchange"); # read screen dump into $a @a=3D<FP>; for ($i=3D0; $i<@a-1; $i++) { print $a[$i]; usleep(50); } # special case, if the prompt is the last thing in the dump # append a space (you may need to uncomment this) #$a[$i] =3D~ s/(\d+])$/\1 /sm; print $a[$i]." "; # delete the screen dump file unlink "/tmp/screen-exchange"; And finally, to use this, you would simply do c-^ c-l and it redraws the scrollback buffer. This is extremely useful when you change screens and change back to a screen and you want to scroll back up. In my opinion, Screen should do this by default! And, if anyone else has a better way of redrawing a screen's scrollback buffer than this, please post! I spent ages working this out. The only thing it does not redraw is the color, though I have 'paste font' enabled. Hope this helps! Michael Grant
signature.asc
Description: PGP signature