Strict Standards: Declaration of action_plugin_loglog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/public/screen/lib/plugins/loglog/action.php on line 15

Strict Standards: Declaration of action_plugin_captcha::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/public/screen/lib/plugins/captcha/action.php on line 0
GNU screen [interface]

Differences

This shows you the differences between two versions of the page.

interface [2010/01/23 19:34]
asciiphil created
interface [2010/01/28 16:53] (current)
asciiphil Describe the commands.
Line 1: Line 1:
-This is just a skeleton for now.+====== Interacting with screen ======
-  * ''[[commands:bind]]'' +===== Basics ===== 
-  * ''[[commands:bindkey]]'' + 
-  * ''[[commands:digraph]]'' +This set of commands is mostly about customizing ''screen'''s interface, 
-  * ''[[commands:help]]'' +in terms of keybindings.  The most important command is probably 
-  * ''[[commands:mapdefault]]'' +''[[commands:escape]]'', which lets you change the default ''screen'' 
-  * ''[[commands:mapnotnext]]'' +prefix escape character.  ''emacs'' users, in particular, will want to use 
-  * ''[[commands:maptimeout]]'' +a different prefix, since ''C-a'' is "beginning of line" in ''emacs''. 
-  * ''[[commands:markkeys]]'' + 
-  * ''[[commands:escape]]'' +The ''[[commands:bind]]'' and ''[[commands:bindkey]]'' commands allow you 
-  * ''[[commands:meta]]'' +to add or redefine ''screen'' keybindings.  Both can associate arbitrary 
-  * ''[[commands:process]]'' +''screen'' commands with specific keypresses.  ''[[commands:bind]]'' 
-  * ''[[commands:stuff]]'' +defines keys in ''screen'''s main command class, so the command 
-  * ''[[commands:xoff]]'' +"''[[commands:bind]] K [[commands:kill]]''" would cause the key sequence 
-  * ''[[commands:xon]]''+''C-a K'' to trigger the ''[[commands:kill]]'' command. 
 +''[[commands:bindkey]]'' is more general; it can bind commands to any 
 +keypress, not just ones preceded by ''C-a''.  ''[[commands:bindkey]]'' can 
 +also modify the keypresses used in [[commands:copy]] mode. 
 + 
 +You can use ''[[commands:help|C-a ?]]'' to see what the current set of 
 +keybindings is. 
 + 
 +===== Extras ===== 
 + 
 +==== bindkey Tables ==== 
 + 
 +Technically, what ''[[commands:bindkey]]'' does is modify one of 
 +''screen'''s three input translation tables.  Normally, when you press a 
 +key, ''screen'' checks the user translation table to see if they key is 
 +there; if it is, then the bound action is taken.  ''[[commands:bindkey]]'' 
 +changes the user translation table by default, and most arbitrary 
 +keybindings should go there.  If the user translation table doesn't have 
 +an entry for the key pressed, ''screen'' then checks the default 
 +translation table; if nothing is there, the keypress gets sent to the 
 +window.  The default translation table is used for keybindings that affect 
 +''screen'''s terminal emulation, like the particular escape sequence to 
 +send for a function key. 
 + 
 +The third input translation table is for [[commands:copy]] mode.  You can 
 +use it to change the keys used in that mode.  This works a little 
 +differently than the other modes, because there aren't commands for the 
 +things you can do in copy mode.  You can, of course, bind any of 
 +''screen'''s normal commands, but if you want to trigger any 
 +copy-mode-specific commands, you have to use ''[[commands:stuff]]'' and 
 +stuff the key sequence for the action you want to take.  You can use this 
 +functionality to remap copy mode key bindings, but that's better done with 
 +the ''[[commands:markkeys]]'' command; ''[[commands:bindkey]]'' is more 
 +useful when you want to chain several actions together. 
 + 
 +''[[commands:bindkey]]'' updates the user table by default, and the 
 +default and copy mode tables with the ''-d'' and ''-m'' options, 
 +respectively.  If you call ''[[commands:bindkey]]'' without giving it a 
 +keybinding, it will display the current bindings for the selected mode. 
 + 
 +==== Command Classes ==== 
 + 
 +Command classes are how you can implement multi-key bindings in 
 +''screen''.  Basically, ''screen'' has to do //something// for every key 
 +the user presses.  (Modifiers don't count; ''C-a'' is considered a single 
 +keypress.)  To effect a multi-key sequence, you have to tell ''screen'' 
 +that the first keypress activates a command class, where that command 
 +class contains a binding for the next key, and so on.  This is effectively 
 +how normal ''screen'' keybindings work: the ''C-a'' activates the default 
 +command class, which contains all of the default bindings, plus any that 
 +you've added with ''[[commands:bind]]''. 
 + 
 +You "activate a command class" with the ''[[commands:command]]'' command. 
 +Without any arguments, it activates the default command class (just like 
 +''C-a'' does).  Its ''-c'' argument activates whatever class is provided 
 +to it.  Similarly, ''[[commands:bind]]'''s ''-c'' option makes a binding 
 +in the specified command class. 
 + 
 +(To be fair, command classes are just the most flexible way to implement 
 +multi-key bindings in ''screen''.  The ''[[commands:bindkey]]'' command 
 +will bind commands to strings as well as single characters.  If the 
 +characters in the string arrive quickly enough (faster than 
 +''[[commands:maptimeout]]''), they will trigger the binding.  The ''-t'' 
 +option will even disable the timeout.) 
 + 
 +==== Quoting ==== 
 + 
 +Sometimes you don't want to activate a keybinding.  That's where 
 +''[[commands:mapdefault]]'' comes in; it causes the next keypress to not 
 +be checked against the user input translation table (see 
 +[[interface#bindkey Tables]] above).  This bypassess all ''screen'' 
 +keybindings except the ones needed for its terminal emulation.  If you 
 +need to bypass the default input translation table too, use 
 +''[[commands:mapnotnext]]''. 
 + 
 +==== Faking Keypresses ==== 
 + 
 +The ''[[commands:stuff]]'' command will take a string and send it directly 
 +to the current window.  See the [[interface#Examples]] section for some 
 +places where it's useful. 
 + 
 +===== Keybindings ===== 
 + 
 +  * ''[[commands:meta|C-a a]]'' - send a literal ''C-a'' to the window. 
 +  * ''[[commands:help|C-a ?]]'' - display the current set of keybindings. 
 + 
 +===== Commands ===== 
 + 
 +  * ''[[commands:bind]]'' - Binds a command to a key as a standard ''screen'' command. 
 +  * ''[[commands:bindkey]]'' - Binds a command to an arbitrary keypress in any of ''screen'''s input translation tables. 
 +  * ''[[commands:command]]'' - Activates a command class. 
 +  * ''[[commands:help]]'' - Displays the current keybindings. 
 +  * ''[[commands:mapdefault]]'' - Prevents the next keypress from being looked up in the user input translation table. 
 +  * ''[[commands:mapnotnext]]'' - Prevents the next keypress from being looked up in any input translation table. 
 +  * ''[[commands:maptimeout]]'' - Sets the inter-character timeout for multi-character keybindings. 
 +  * ''[[commands:markkeys]]'' - Changes the keybindings for [[commands:copy]] mode. 
 +  * ''[[commands:escape]]'' - Changes ''screen'''s command prefix character. 
 +  * ''[[commands:meta]]'' - Sends the ''screen'' command prefix character to the current window. 
 +  * ''[[commands:stuff]]'' - Sends a string to the current window. 
 + 
 +===== Examples ===== 
 + 
 +==== Different Prefix Keys ==== 
 + 
 +''vi'' users might want to use the escape character as their prefix key. 
 +When doing that, you have to decide whether two escapes in a row will call 
 +''[[commands:other]]'' (to switch to the most recently visited window) or 
 +''[[commands:meta]]'' (to send an escape character to the window).  Here's 
 +an example of each: 
 + 
 +<code> 
 +# ESC ESC calls meta 
 +escape ^[^[ 
 +# ESC o calls other 
 +bind o other 
 +</code> 
 + 
 +<code> 
 +# ESC [ calls meta 
 +escape ^[[ 
 +# ESC ESC calls other by default 
 +</code> 
 + 
 +''emacs'' users will probably want to remap the escape character just 
 +because it interferes with ''C-a'' in ''emacs''.  One option is to use 
 +''C-z'' instead, as it's close to ''C-a'' and ''screen'' lets you open new 
 +programs in new windows, rather than having to suspend the current program 
 +first: 
 + 
 +<code> 
 +escape ^zz 
 +</code> 
 + 
 +==== bindkey Examples ==== 
 + 
 +The default input translation table is for terminal behavior.  To deal 
 +with a terminal that wasn't sending the right character for its backspace 
 +button, you could use screen to "fix" the keypress: 
 + 
 +<code> 
 +bindkey -d -k kb stuff "\177" 
 +</code> 
 + 
 +The copy mode input translation table can be used to automate things in 
 +copy mode.  This causes ''C-g'' to find the first occurrence of "foo" in 
 +the buffer and copy the entire line it's on: 
 + 
 +<code> 
 +bindkey -m ^G stuff "g/foo\012Y" 
 +</code> 
 + 
 +==== Command Class Examples ==== 
 + 
 +You can use the default command class to make a second escape key. 
 +Suppose you want both ''C-z'' and ''C-\'' to be escape keys.  You could do 
 +it like this: 
 + 
 +<code> 
 +escape ^zz 
 +bindkey ^\ command 
 +</code> 
 + 
 +Let's say you wanted to to make the split commands a little more mnemonic 
 +and use ''C-a s h'' and ''C-a s v'' for "split horizontally" and "split 
 +vertically", respectively.  Here's something that would work: 
 + 
 +<code> 
 +bind s command -c split_class 
 +bind -c split_class h split 
 +bind -c split_class v split -v 
 +</code> 
 + 
 +The ''[[commands:bind]]'' page shows some further examples that use 
 +command classes to make bindings to select windows numbered higher than 9. 
 + 
 +==== Quoting Examples ==== 
 + 
 +It's often useful to have a quote key that sends the next keypress through 
 +unintercepted. Here's how to accomplish that: 
 + 
 +<code> 
 +bind ^Q mapdefault 
 +</code> 
 + 
 +With that, you can press ''C-a C-q //another-key//'' and //another-key// 
 +will be passed through to the window (unless it's affected by the default 
 +input translation table, but you generally want those to still be mapped, 
 +because they affect ''screen'''s terminal definitions). 
 + 
 +==== emacs-Friendly copy Mode ==== 
 + 
 +The keybindings in [[commands:copy]] mode are mostly based on ''vi'' keys 
 +(although it has ''emacs''-style incremental searching). Here's a 
 +remapping that makes some of the keys closer: 
 + 
 +<code> 
 +markkeys j=^N:k=^P:l=^F:0=^A:$=^E:^F=^V 
 +bindkey -m -t ^[v    stuff ^B 
 +bindkey -m    ^B     stuff h 
 +bindkey -m -t ^[a    stuff \^ 
 +bindkey -m -t ^[f    stuff w 
 +bindkey -m -t ^[b    stuff b 
 +bindkey -m -t ^[0^[r stuff H 
 +# Nothing for 'M' 
 +bindkey -m -t ^[-^[r stuff L 
 +bindkey -m -t ^[<    stuff g 
 +bindkey -m -t ^[>    stuff G 
 +bindkey -m -t ^[d    stuff " e " 
 +</code> 
 + 
 +''[[commands:markkeys]]'' is used for the single-character bindings, while 
 +''[[commands:bindkey]]'' is used for the multi-character keys.  (You can't 
 +specify a meta key, but you can use the combination with escape that is 
 +equivalent.  ''xterm'' can even be set up to send an escape character when 
 +a meta-key combination is pressed.) 
 + 
 +A more complete mapping is left as an exercise for the reader. 
 + 
 +==== xterm-Style Scrolling ==== 
 + 
 +In ''xterm'', shift-PgUp and shift-PgDn move through the terminal's 
 +scrollback buffer.  ''screen'' keeps a separate scrollback buffer for each 
 +window, so this example lets you use those keypresses to move around 
 +''screen'''s scrollback buffer. 
 + 
 +First, you need to disable scrolling in ''xterm'', so this goes in your 
 +.Xresources file: 
 + 
 +<file> 
 +XTerm.vt100.translations: #override \n\ 
 +    Shift <Key>Prior:string(0x1b) string("[5;2~") \n\ 
 +    Shift <Key>Next:string(0x1b) string("[6;2~") 
 +</file> 
 + 
 +Then you need to make shift-PgUp enter [[commands:copy]] mode and go back 
 +a page, and both key combinations move around in copy mode.  This goes in 
 +your .screenrc: 
 + 
 +<code> 
 +bindkey "^[[5;2~" eval "copy" "stuff ^u" 
 +bindkey -m "^[[5;2~" stuff ^u 
 +bindkey -m "^[[6;2~" stuff ^d 
 +</code>
 
interface.1264275279.txt.gz · Last modified: 2010/01/23 19:34 by asciiphil
Recent changes RSS feed GNU General Public License Driven by DokuWiki