I would like to make a custom keybinding in GNU Screen which, when some key is pressed, like F1, is the equivalent of pressing Enter and then the Screen next command.

I know that bindkey can bind keys to Screen commands, but could it also be used to trigger some other command line input, such as the mere pressing of the "enter" key?

1 Answer 1


Yes, you can use the stuff screen command. From the man pages of screen:

   stuff [string]

   Stuff  the string string in the input buffer of the current window.  This is
   like the "paste" command but with much less overhead.  Without  a  paramter,
   screen  will  prompt  for a string to stuff.  You cannot paste large buffers
   with the "stuff" command. It is most  useful  for  key  bindings.  See  also

Also in the man pages you can see the following examples:

           bindkey -k k1 select 1
   Make the "F1" key switch to window one.

           bindkey -t foo stuff barfoo
   Make  "foo"  an  abbreviation  of the word "barfoo". Timeout is disabled so that
   users can type slowly.

So for instance, you can add the following line to your $HOME/.inputrc file to bind F1 writing \n to the input buffer (the equivalent of pressing Enter).

bindkey -k k1 stuff "\n"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .