From 80fc46c04befb5a8dcba984d760b7ab90d91f39b Mon Sep 17 00:00:00 2001 From: Brandon Fuller Date: Wed, 17 Jun 2026 16:31:39 -0400 Subject: [PATCH] Add function to attach tmux sessions/windows to each other --- .functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.functions b/.functions index 7ad88417..8c0996c0 100644 --- a/.functions +++ b/.functions @@ -121,3 +121,18 @@ function git-clean-branches () { echo "Use 'git-clean-branches | xargs git branch -d' to actually delete these." >&2 } + +# TMUX: Create a new tmux session that shares windows with an existing session, but whose +# active window(s) remain independent of the existing session's (i.e. they don't mirror each other) +# +# USAGE: `tc 2 1` => `tmux new-session -s2 -t1` +# EXPL: This creates a new session named "2" that shares all the same windows with the session named "1" +# +# NOTE: This command will attempt to attach to a session named "0" (which is the default name) if +# a second argument isn't given: +# USAGE: `tc 2` => `tmux new-session -s2 -t0` +# EXPL: This creates a new session named "2" that shares all the same windows with the session named "0" + +function tc() { + tmux new-session -s"${1}" -t"${2:-0}" +}