Managing local and remote nested tmux sessions?

not sure if i’m barking up the wrong tree or not. but something i’ve been running into more frequently is wanting to use tmux inside of tmux. ie.

i have a local terminal window going (alacritty), within this terminal window i launch tmux.
inside the tmux session i create a new window, and within this window i ssh into a remote box, mostly another local computer on my network (this time being a macos vm (used for github actions ci/cd)).

now i’m ssh’ed into this mojave box (one of three vm’s going) i’d launch tmux once ssh’ed into the remote computer, but all of my local bindings are picked up and conflict with the remote tmux instance.

i know nesting tmux inside of tmux can be a slippery slope, but this use case has come up more often than not.

and a lot less elegant workflow is to create another pane/window within my local tmux instance and then launch a new ssh session, and soon i’m ssh’ed into the same box multiple times making things quite cumbersome.

does anybody have a good workflow for using tmux inside of tmux ie. local tmux and remote tmux to easily have all existing bindings present for local and remote sessions?

you could set a separate prefix for the nested session like this:

# set prefix key to c-f instead of default c-b
unbind C-b
set -g prefix C-f
bind C-f send-prefix

# alterate keybind for nested session
unbind C-b
bind-key -n C-b send-prefix