Created
November 22, 2012 06:15
-
-
Save iley/4129652 to your computer and use it in GitHub Desktop.
Script to link tmux windows between sessions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use constant WINDOWS => 3; | |
| my $name = shift; | |
| $name or die "Usage: tmux-link name"; | |
| system "tmux rename-session $name"; | |
| my @sessions = | |
| grep {$_ ne $name} | |
| map {s/^([^:]+):.*$/$1/; $_} | |
| split /\n/, `tmux list-sessions`; | |
| my $open_windows = split /\n/, `tmux list-windows`; | |
| system "tmux new-window" for (($open_windows+1)..WINDOWS); | |
| system "tmux select-window -t :1"; | |
| for my $session (@sessions) { | |
| for my $i (1..WINDOWS) { | |
| system "tmux link-window -dk -s $name:$i -t $session:$i"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment