Binding arrow keys in GNU Screen
up vote
2
down vote
favorite
I'm a newcomer to GNU Screen and so far I'm liking it. However there is something I can't quite get to work the way I could in tmux.
I want to make it so that Ctrl-a "arrow key" changes focus between my windows. I typically have many splits in my terminal window.
I've searched around but been unable to find a config that works. Note I do not want to switch between windows, just the focus.
Bonus points if someone could explain the difference between "bind" and "bindkey" to my addled brain.
Cheers
shortcut-keys gnu-screen
add a comment |
up vote
2
down vote
favorite
I'm a newcomer to GNU Screen and so far I'm liking it. However there is something I can't quite get to work the way I could in tmux.
I want to make it so that Ctrl-a "arrow key" changes focus between my windows. I typically have many splits in my terminal window.
I've searched around but been unable to find a config that works. Note I do not want to switch between windows, just the focus.
Bonus points if someone could explain the difference between "bind" and "bindkey" to my addled brain.
Cheers
shortcut-keys gnu-screen
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm a newcomer to GNU Screen and so far I'm liking it. However there is something I can't quite get to work the way I could in tmux.
I want to make it so that Ctrl-a "arrow key" changes focus between my windows. I typically have many splits in my terminal window.
I've searched around but been unable to find a config that works. Note I do not want to switch between windows, just the focus.
Bonus points if someone could explain the difference between "bind" and "bindkey" to my addled brain.
Cheers
shortcut-keys gnu-screen
I'm a newcomer to GNU Screen and so far I'm liking it. However there is something I can't quite get to work the way I could in tmux.
I want to make it so that Ctrl-a "arrow key" changes focus between my windows. I typically have many splits in my terminal window.
I've searched around but been unable to find a config that works. Note I do not want to switch between windows, just the focus.
Bonus points if someone could explain the difference between "bind" and "bindkey" to my addled brain.
Cheers
shortcut-keys gnu-screen
shortcut-keys gnu-screen
asked Apr 6 '16 at 16:15
big_plums
164
164
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33
add a comment |
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
Since :bind
will not accept weird virtual characters like the arrow-keys — only keypresses that have ASCII-codes or stuff like ctrlthingThatHasAsciiCode — I think using :bindkey
is the simplest way to get what you're after. For me, the following worked under GNU screen 4.06.01 in xterm and could be added either into "~/.screenrc" (affects just you) or "/etc/screenrc" (meant to apply system-wide):
# ctrlA then right-arrow-key jumps active cursor one pane to the right:
bindkey "^A^[OC" focus right
# ctrlA then left-arrow-key jumps active cursor one pane to the left:
bindkey "^A^[OC" focus left
# ctrlA then up-arrow-key jumps active cursor one pane above current:
bindkey "^A^[OA" focus up
# ctrlA then up-arrow-key jumps active cursor one pane below current:
bindkey "^A^[OB" focus down
Depending on your terminal and settings, the codes you need to place after the "^A" may be different for you. To determine what these codes are, I prefer to use vim
; open it and then press i to enter edit-mode, then press ctrlv to take raw input, then hit the key or key-combination in question * **.
When you use my approach, you'll need to type your ctrlarrowKey command fairly swiftly; screen
stops listening for custom bindings if you pause for too long between keystrokes. If it's expiring too quickly, use :bindkey -t
instead of :bindkey
to disable the timer.
* Note that unlike in vim
, screen will not like it if you insert the actual metacharacter escapes into ".screenrc" or other files you might source; simply use literal, individual '^' and '[', not the weird combined version that vim
can output (at least, that seemed to screw things up for me).
** Some people determine special key-codes by running cat
(by itself) in the terminal, and then pressing the key(s) in question (before using ctrlc to quit). I don't use this approach so YMMV.
+1 for thevim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !
– MoonSweep
Nov 30 at 4:30
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f754513%2fbinding-arrow-keys-in-gnu-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Since :bind
will not accept weird virtual characters like the arrow-keys — only keypresses that have ASCII-codes or stuff like ctrlthingThatHasAsciiCode — I think using :bindkey
is the simplest way to get what you're after. For me, the following worked under GNU screen 4.06.01 in xterm and could be added either into "~/.screenrc" (affects just you) or "/etc/screenrc" (meant to apply system-wide):
# ctrlA then right-arrow-key jumps active cursor one pane to the right:
bindkey "^A^[OC" focus right
# ctrlA then left-arrow-key jumps active cursor one pane to the left:
bindkey "^A^[OC" focus left
# ctrlA then up-arrow-key jumps active cursor one pane above current:
bindkey "^A^[OA" focus up
# ctrlA then up-arrow-key jumps active cursor one pane below current:
bindkey "^A^[OB" focus down
Depending on your terminal and settings, the codes you need to place after the "^A" may be different for you. To determine what these codes are, I prefer to use vim
; open it and then press i to enter edit-mode, then press ctrlv to take raw input, then hit the key or key-combination in question * **.
When you use my approach, you'll need to type your ctrlarrowKey command fairly swiftly; screen
stops listening for custom bindings if you pause for too long between keystrokes. If it's expiring too quickly, use :bindkey -t
instead of :bindkey
to disable the timer.
* Note that unlike in vim
, screen will not like it if you insert the actual metacharacter escapes into ".screenrc" or other files you might source; simply use literal, individual '^' and '[', not the weird combined version that vim
can output (at least, that seemed to screw things up for me).
** Some people determine special key-codes by running cat
(by itself) in the terminal, and then pressing the key(s) in question (before using ctrlc to quit). I don't use this approach so YMMV.
+1 for thevim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !
– MoonSweep
Nov 30 at 4:30
add a comment |
up vote
2
down vote
Since :bind
will not accept weird virtual characters like the arrow-keys — only keypresses that have ASCII-codes or stuff like ctrlthingThatHasAsciiCode — I think using :bindkey
is the simplest way to get what you're after. For me, the following worked under GNU screen 4.06.01 in xterm and could be added either into "~/.screenrc" (affects just you) or "/etc/screenrc" (meant to apply system-wide):
# ctrlA then right-arrow-key jumps active cursor one pane to the right:
bindkey "^A^[OC" focus right
# ctrlA then left-arrow-key jumps active cursor one pane to the left:
bindkey "^A^[OC" focus left
# ctrlA then up-arrow-key jumps active cursor one pane above current:
bindkey "^A^[OA" focus up
# ctrlA then up-arrow-key jumps active cursor one pane below current:
bindkey "^A^[OB" focus down
Depending on your terminal and settings, the codes you need to place after the "^A" may be different for you. To determine what these codes are, I prefer to use vim
; open it and then press i to enter edit-mode, then press ctrlv to take raw input, then hit the key or key-combination in question * **.
When you use my approach, you'll need to type your ctrlarrowKey command fairly swiftly; screen
stops listening for custom bindings if you pause for too long between keystrokes. If it's expiring too quickly, use :bindkey -t
instead of :bindkey
to disable the timer.
* Note that unlike in vim
, screen will not like it if you insert the actual metacharacter escapes into ".screenrc" or other files you might source; simply use literal, individual '^' and '[', not the weird combined version that vim
can output (at least, that seemed to screw things up for me).
** Some people determine special key-codes by running cat
(by itself) in the terminal, and then pressing the key(s) in question (before using ctrlc to quit). I don't use this approach so YMMV.
+1 for thevim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !
– MoonSweep
Nov 30 at 4:30
add a comment |
up vote
2
down vote
up vote
2
down vote
Since :bind
will not accept weird virtual characters like the arrow-keys — only keypresses that have ASCII-codes or stuff like ctrlthingThatHasAsciiCode — I think using :bindkey
is the simplest way to get what you're after. For me, the following worked under GNU screen 4.06.01 in xterm and could be added either into "~/.screenrc" (affects just you) or "/etc/screenrc" (meant to apply system-wide):
# ctrlA then right-arrow-key jumps active cursor one pane to the right:
bindkey "^A^[OC" focus right
# ctrlA then left-arrow-key jumps active cursor one pane to the left:
bindkey "^A^[OC" focus left
# ctrlA then up-arrow-key jumps active cursor one pane above current:
bindkey "^A^[OA" focus up
# ctrlA then up-arrow-key jumps active cursor one pane below current:
bindkey "^A^[OB" focus down
Depending on your terminal and settings, the codes you need to place after the "^A" may be different for you. To determine what these codes are, I prefer to use vim
; open it and then press i to enter edit-mode, then press ctrlv to take raw input, then hit the key or key-combination in question * **.
When you use my approach, you'll need to type your ctrlarrowKey command fairly swiftly; screen
stops listening for custom bindings if you pause for too long between keystrokes. If it's expiring too quickly, use :bindkey -t
instead of :bindkey
to disable the timer.
* Note that unlike in vim
, screen will not like it if you insert the actual metacharacter escapes into ".screenrc" or other files you might source; simply use literal, individual '^' and '[', not the weird combined version that vim
can output (at least, that seemed to screw things up for me).
** Some people determine special key-codes by running cat
(by itself) in the terminal, and then pressing the key(s) in question (before using ctrlc to quit). I don't use this approach so YMMV.
Since :bind
will not accept weird virtual characters like the arrow-keys — only keypresses that have ASCII-codes or stuff like ctrlthingThatHasAsciiCode — I think using :bindkey
is the simplest way to get what you're after. For me, the following worked under GNU screen 4.06.01 in xterm and could be added either into "~/.screenrc" (affects just you) or "/etc/screenrc" (meant to apply system-wide):
# ctrlA then right-arrow-key jumps active cursor one pane to the right:
bindkey "^A^[OC" focus right
# ctrlA then left-arrow-key jumps active cursor one pane to the left:
bindkey "^A^[OC" focus left
# ctrlA then up-arrow-key jumps active cursor one pane above current:
bindkey "^A^[OA" focus up
# ctrlA then up-arrow-key jumps active cursor one pane below current:
bindkey "^A^[OB" focus down
Depending on your terminal and settings, the codes you need to place after the "^A" may be different for you. To determine what these codes are, I prefer to use vim
; open it and then press i to enter edit-mode, then press ctrlv to take raw input, then hit the key or key-combination in question * **.
When you use my approach, you'll need to type your ctrlarrowKey command fairly swiftly; screen
stops listening for custom bindings if you pause for too long between keystrokes. If it's expiring too quickly, use :bindkey -t
instead of :bindkey
to disable the timer.
* Note that unlike in vim
, screen will not like it if you insert the actual metacharacter escapes into ".screenrc" or other files you might source; simply use literal, individual '^' and '[', not the weird combined version that vim
can output (at least, that seemed to screw things up for me).
** Some people determine special key-codes by running cat
(by itself) in the terminal, and then pressing the key(s) in question (before using ctrlc to quit). I don't use this approach so YMMV.
edited Nov 30 at 14:01
MoonSweep
34817
34817
answered Oct 12 '17 at 0:28
koyae
1213
1213
+1 for thevim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !
– MoonSweep
Nov 30 at 4:30
add a comment |
+1 for thevim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !
– MoonSweep
Nov 30 at 4:30
+1 for the
vim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !– MoonSweep
Nov 30 at 4:30
+1 for the
vim
trick, this is truly wonderful, it seems to work with any key combination I tried so far (Alt+arrows, Ctrl+arrows, and so on). Thanks a million !– MoonSweep
Nov 30 at 4:30
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f754513%2fbinding-arrow-keys-in-gnu-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
bind binds a command to a key. bindkey manages the input translation tables. These are tables that determine how Screen reacts to certain sequences of characters. gnu.org/software/screen/manual/html_node/Key-Binding.html
– Tobias
Apr 6 '16 at 17:33