Tmux keybinding to swap pane left or right
I'm aware that :swap-pane -U
and :swap-pane -D
will swap panes up or down, but I'd like a keybinding to swap panes left and right.
The only way I can think of to do this would be to first determine the pane index of the current pane, then run :select-pane -R
or -L
and determine its index, and finally run :swap-pane -s (first pane index) -t (second pane index)
.
I'm just not sure how to do this in .tmux.conf
- is it possible to have subcommands which return something within another command?
For example, something like this:
bind-key -n C-{ swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -L'**
bind-key -n C-} swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -R'**
tmux
add a comment |
I'm aware that :swap-pane -U
and :swap-pane -D
will swap panes up or down, but I'd like a keybinding to swap panes left and right.
The only way I can think of to do this would be to first determine the pane index of the current pane, then run :select-pane -R
or -L
and determine its index, and finally run :swap-pane -s (first pane index) -t (second pane index)
.
I'm just not sure how to do this in .tmux.conf
- is it possible to have subcommands which return something within another command?
For example, something like this:
bind-key -n C-{ swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -L'**
bind-key -n C-} swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -R'**
tmux
add a comment |
I'm aware that :swap-pane -U
and :swap-pane -D
will swap panes up or down, but I'd like a keybinding to swap panes left and right.
The only way I can think of to do this would be to first determine the pane index of the current pane, then run :select-pane -R
or -L
and determine its index, and finally run :swap-pane -s (first pane index) -t (second pane index)
.
I'm just not sure how to do this in .tmux.conf
- is it possible to have subcommands which return something within another command?
For example, something like this:
bind-key -n C-{ swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -L'**
bind-key -n C-} swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -R'**
tmux
I'm aware that :swap-pane -U
and :swap-pane -D
will swap panes up or down, but I'd like a keybinding to swap panes left and right.
The only way I can think of to do this would be to first determine the pane index of the current pane, then run :select-pane -R
or -L
and determine its index, and finally run :swap-pane -s (first pane index) -t (second pane index)
.
I'm just not sure how to do this in .tmux.conf
- is it possible to have subcommands which return something within another command?
For example, something like this:
bind-key -n C-{ swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -L'**
bind-key -n C-} swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -R'**
tmux
tmux
asked May 22 '16 at 2:15
DC_DC_
787
787
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
:bind-key -n C-{ select-pane -L ; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also, swap-pane -s {right-of}
seems to work.
Here is the list of ways to refer to other panes:
{last} ! The last (previously active) pane
{next} + The next pane by number
{previous} - The previous pane by number
{top} The top pane
{bottom} The bottom pane
{left} The leftmost pane
{right} The rightmost pane
{top-left} The top-left pane
{top-right} The top-right pane
{bottom-left} The bottom-left pane
{bottom-right} The bottom-right pane
{up-of} The pane above the active pane
{down-of} The pane below the active pane
{left-of} The pane to the left of the active pane
{right-of} The pane to the right of the active pane
See the online man page for reference.
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
add a comment |
One can also add following line to ~/.tmux.conf
bind v swap-pane -s '!' -t $TMUX_PANE
This will interchange current pane with the last visited pane. Consecutively go to the two panes needed to be interchanged and use <prefix>v
(above command) to perform the swap. Note that <prefix>q
shows the id of the panes. The additional advantage is that the swapping also works across different windows.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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',
autoActivateHeartbeat: false,
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%2fsuperuser.com%2fquestions%2f1079462%2ftmux-keybinding-to-swap-pane-left-or-right%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
:bind-key -n C-{ select-pane -L ; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also, swap-pane -s {right-of}
seems to work.
Here is the list of ways to refer to other panes:
{last} ! The last (previously active) pane
{next} + The next pane by number
{previous} - The previous pane by number
{top} The top pane
{bottom} The bottom pane
{left} The leftmost pane
{right} The rightmost pane
{top-left} The top-left pane
{top-right} The top-right pane
{bottom-left} The bottom-left pane
{bottom-right} The bottom-right pane
{up-of} The pane above the active pane
{down-of} The pane below the active pane
{left-of} The pane to the left of the active pane
{right-of} The pane to the right of the active pane
See the online man page for reference.
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
add a comment |
:bind-key -n C-{ select-pane -L ; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also, swap-pane -s {right-of}
seems to work.
Here is the list of ways to refer to other panes:
{last} ! The last (previously active) pane
{next} + The next pane by number
{previous} - The previous pane by number
{top} The top pane
{bottom} The bottom pane
{left} The leftmost pane
{right} The rightmost pane
{top-left} The top-left pane
{top-right} The top-right pane
{bottom-left} The bottom-left pane
{bottom-right} The bottom-right pane
{up-of} The pane above the active pane
{down-of} The pane below the active pane
{left-of} The pane to the left of the active pane
{right-of} The pane to the right of the active pane
See the online man page for reference.
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
add a comment |
:bind-key -n C-{ select-pane -L ; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also, swap-pane -s {right-of}
seems to work.
Here is the list of ways to refer to other panes:
{last} ! The last (previously active) pane
{next} + The next pane by number
{previous} - The previous pane by number
{top} The top pane
{bottom} The bottom pane
{left} The leftmost pane
{right} The rightmost pane
{top-left} The top-left pane
{top-right} The top-right pane
{bottom-left} The bottom-left pane
{bottom-right} The bottom-right pane
{up-of} The pane above the active pane
{down-of} The pane below the active pane
{left-of} The pane to the left of the active pane
{right-of} The pane to the right of the active pane
See the online man page for reference.
:bind-key -n C-{ select-pane -L ; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also, swap-pane -s {right-of}
seems to work.
Here is the list of ways to refer to other panes:
{last} ! The last (previously active) pane
{next} + The next pane by number
{previous} - The previous pane by number
{top} The top pane
{bottom} The bottom pane
{left} The leftmost pane
{right} The rightmost pane
{top-left} The top-left pane
{top-right} The top-right pane
{bottom-left} The bottom-left pane
{bottom-right} The bottom-right pane
{up-of} The pane above the active pane
{down-of} The pane below the active pane
{left-of} The pane to the left of the active pane
{right-of} The pane to the right of the active pane
See the online man page for reference.
edited Feb 17 '17 at 15:30
lleaff
1034
1034
answered May 24 '16 at 18:39
Isaac HansonIsaac Hanson
47327
47327
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
add a comment |
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
Awesome! I had no idea that you could reference those variables, that's super useful. I'll award the bounty as soon as it allows me to, thanks! I was referring to this man page which I guess is probably outdated because my local tmux manpage lists these variables while that one doesn't.
– DC_
May 25 '16 at 5:55
1
1
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Great! this is the man page I used. also has similar info for "windows" in addition to "panes".
– Isaac Hanson
May 25 '16 at 11:55
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
Those variables are a god-send. How come so few answers and tutorials mention them, I wish I knew about this earlier.
– lleaff
Feb 17 '17 at 14:59
add a comment |
One can also add following line to ~/.tmux.conf
bind v swap-pane -s '!' -t $TMUX_PANE
This will interchange current pane with the last visited pane. Consecutively go to the two panes needed to be interchanged and use <prefix>v
(above command) to perform the swap. Note that <prefix>q
shows the id of the panes. The additional advantage is that the swapping also works across different windows.
add a comment |
One can also add following line to ~/.tmux.conf
bind v swap-pane -s '!' -t $TMUX_PANE
This will interchange current pane with the last visited pane. Consecutively go to the two panes needed to be interchanged and use <prefix>v
(above command) to perform the swap. Note that <prefix>q
shows the id of the panes. The additional advantage is that the swapping also works across different windows.
add a comment |
One can also add following line to ~/.tmux.conf
bind v swap-pane -s '!' -t $TMUX_PANE
This will interchange current pane with the last visited pane. Consecutively go to the two panes needed to be interchanged and use <prefix>v
(above command) to perform the swap. Note that <prefix>q
shows the id of the panes. The additional advantage is that the swapping also works across different windows.
One can also add following line to ~/.tmux.conf
bind v swap-pane -s '!' -t $TMUX_PANE
This will interchange current pane with the last visited pane. Consecutively go to the two panes needed to be interchanged and use <prefix>v
(above command) to perform the swap. Note that <prefix>q
shows the id of the panes. The additional advantage is that the swapping also works across different windows.
edited Jan 3 at 17:01
answered Jan 3 at 7:40
Nishan JainNishan Jain
112
112
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1079462%2ftmux-keybinding-to-swap-pane-left-or-right%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