Search code examples
gnu-screen

GNU Screen: Reverse focus tabbing


Is it possible to bind Ctrl+a Shift+Tab to switch focus to the previous window in the list (much like Ctrl+a p but changing the focus)?

Specifically, I want to skip from the first to the last. For example, here is a screen profile:

# Vertical split with two on right
#
# +---+---+
# |   |   |
# |   |---|
# |   |   |
# +---+---+
#
split -v
screen bash
title "main"
focus
split
screen bash
title "script"
focus
screen bash
title "interpreter"
focus left

# ctrl+a navigating regions
bind j focus down
bind k focus up
bind h focus left
bind l focus right

Focus starts in the top left screen. I'd like to jump straight to the bottom right. I can do this by hitting Ctrl+a Tab twice. Is there a single command and, if so, how could I bind this to Ctrl+a Shift+Tab?

Edit

Have just found Ctrl+a Ctrl+i switches to the next window as well (strangely not info). I'm on Screen version 4.01.00devel (GNU) 2-May-06

Good workaround

Add the following to your screen profile (or ~/.screenrc)

## ctrl+a navigating regions
bindkey "^j" focus down
bindkey "^k" focus up
bindkey "^h" focus left
bindkey "^l" focus right

Now you can zip around quickly by holding Ctrl + h/j/k/l in a vim-esque style.


Solution

  • The command you're looking for is focus prev.

    Unfortunately, there is no way to bind Shift+Tab, since bind does not allow for modifier keys, and Tab is equivalent to Ctrl+i (which also explains why it's bound to focus instead of info), so you'd have to bind it to a different key.