From db26fc97c69a7228a8ab35c084a380aea337d7bb Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 31 Dec 2025 12:10:52 -0700 Subject: [PATCH] Add Set Up Forwarding Prefix For Nested Session as a tmux TIL --- README.md | 3 ++- ...up-forwarding-prefix-for-nested-session.md | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tmux/set-up-forwarding-prefix-for-nested-session.md diff --git a/README.md b/README.md index 0655292..e8f116b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1713 TILs and counting..._ +_1714 TILs and counting..._ See some of the other learning resources I work on: @@ -1569,6 +1569,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Reset An Option Back To Its Default Value](tmux/reset-an-option-back-to-its-default-value.md) - [Set Environment Variables When Creating Session](tmux/set-environment-variables-when-creating-session.md) - [Set Session Specific Environment Variables](tmux/set-session-specific-environment-variables.md) +- [Set Up Forwarding Prefix For Nested Session](tmux/set-up-forwarding-prefix-for-nested-session.md) - [Show The Current Value For An Option](tmux/show-the-current-value-for-an-option.md) - [Swap Split Panes](tmux/swap-split-panes.md) - [Switch To A Specific Session And Window](tmux/switch-to-a-specific-session-and-window.md) diff --git a/tmux/set-up-forwarding-prefix-for-nested-session.md b/tmux/set-up-forwarding-prefix-for-nested-session.md new file mode 100644 index 0000000..978b55d --- /dev/null +++ b/tmux/set-up-forwarding-prefix-for-nested-session.md @@ -0,0 +1,24 @@ +# Set Up Forwarding Prefix For Nested Session + +I use +[`ctrl-z`](https://github.com/jbranchaud/dotfiles/blob/main/config/tmux/tmux.conf#L57) +(instead of `ctrl-b`) for my tmux prefix key. I also have [`ctrl-z +ctrl-z`](https://github.com/jbranchaud/dotfiles/blob/main/config/tmux/tmux.conf#L138-L139) +configured to toggle back and forth between the previously visited window. + +With that in mind, I needed to set up a specific keybinding to send the prefix +key to an inner (nested) tmux session. That's because sometimes, like with a +tool such as `overmind`, you can end up connected to a tmux session while +already within a tmux session. + +So, I have `Ctrl-z a` send the prefix key to the inner tmux session. This is +what I added to my +[`tmux.conf`](https://github.com/jbranchaud/dotfiles/blob/main/config/tmux/tmux.conf#L167-L168): + +``` +# send prefix to inner tmux session (C-z a) +bind-key a send-prefix +``` + +Simply doing `Ctrl-z d` will detach me from the outer tmux session. If I want to +detach from an inner tmux session, I can use my new keybinding -- `Ctrl-z a d`.