3

In screen is there a way to put a window in between 2 others instead of swapping?

Here is what I have

1 - I want this to become #2
2 - I want this to become #3
3 - I want this to become #1

If I go to screen #3 and enter the command ":number 1", the new order is

1 - I want this to become #1
2 - I want this to become #3
3 - I want this to become #2

Obviously with one more command, I can get what I want. However, when I have 15 windows it is a major pain.

4
  • ok - I've updated the question. Is it clear enough now? Nov 19, 2014 at 16:21
  • The question is off topic here, but if you make it a bit more clear, it could possibly be migrated.
    – kasperd
    Nov 19, 2014 at 16:28
  • oh, sorry. I thought this was the right stackexchange to ask questions about gnu commands. Which one would that be? Was it unclear because I hadn't mentioned screen enough (I just added a link in the first sentence)? I would think that anyone who uses screen could tell what I'm trying to do. Thanks. Nov 19, 2014 at 17:19
  • 4
    The question makes sense now. I think somebody with sufficient privileges should migrate it to unix.stackexchange.com.
    – kasperd
    Nov 19, 2014 at 18:20

1 Answer 1

3
+100

There seems to be no single screen command to do it. However I came up with this script, that can do it by executing enough number commands in a row to do it:

#!/bin/bash

L="$1"
for N in $(eval echo "{$1..$2}")
do
    screen -X at "$L" number "$N"
    L="$N"
done

This can be run from any window within the screen and takes two arguments, the source and destination number of a window to be moved. The source or destination window can match your current window number.

I could find no way to query screen about active and existing window numbers from a script. So I could not make the script default to moving the active window.

You must log in to answer this question.

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