From 9e8a29aee46cf32dbd97cbb2bd80e383116b342a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 29 Apr 2026 11:15:57 +0000 Subject: [PATCH 1/5] Add tmux-ssh function to SSH and attach/create tmux session Implements a shell function that SSHes into a host and attaches to an existing tmux session or creates a new one if none is running. Closes #50 https://claude.ai/code/session_016qMLTkjgjrjoRno37WDr36 --- README.md | 1 + files/shell/functions/tmux-ssh | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 files/shell/functions/tmux-ssh diff --git a/README.md b/README.md index 9b3baee..ea8510d 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,4 @@ make install - `pro [path]` — jump to a project directory under `$PROJECTS_HOME` (`~/Projects` on macOS, `~` on Linux), with tab completion for nested paths - `dfh [topic]` — dotfiles help; run `dfh` for version info and available topics, `dfh tmux` / `dfh fzf` / `dfh vim` for keybinding references extracted from config files +- `tmux-ssh ` — SSH into a machine and attach to an existing tmux session, or create a new one if none is running (e.g. `tmux-ssh kylo` or `tmux-ssh 192.168.86.201`) diff --git a/files/shell/functions/tmux-ssh b/files/shell/functions/tmux-ssh new file mode 100644 index 0000000..ce69a7b --- /dev/null +++ b/files/shell/functions/tmux-ssh @@ -0,0 +1,7 @@ +tmux-ssh() { + if [[ -z "${1:-}" ]]; then + print "Usage: tmux-ssh " + return 1 + fi + ssh -t "$1" 'tmux attach || tmux new-session' +} From 0713e7b76d8989400419d5a36648fb7d90280fa7 Mon Sep 17 00:00:00 2001 From: Jan Groth Date: Sat, 2 May 2026 21:14:23 +1000 Subject: [PATCH 2/5] Add tmux-ssh function to SSH into host and attach/create tmux session Closes #50 --- README.md | 2 +- files/help/tmux | 6 ++++++ files/shell/functions/tmux-ssh | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ea8510d..e4511bc 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ make install - `pro [path]` — jump to a project directory under `$PROJECTS_HOME` (`~/Projects` on macOS, `~` on Linux), with tab completion for nested paths - `dfh [topic]` — dotfiles help; run `dfh` for version info and available topics, `dfh tmux` / `dfh fzf` / `dfh vim` for keybinding references extracted from config files -- `tmux-ssh ` — SSH into a machine and attach to an existing tmux session, or create a new one if none is running (e.g. `tmux-ssh kylo` or `tmux-ssh 192.168.86.201`) +- `tmux-ssh ` — SSH into a host and attach to an existing tmux session (or create one named `main`) diff --git a/files/help/tmux b/files/help/tmux index 69b4f4d..2a61e90 100644 --- a/files/help/tmux +++ b/files/help/tmux @@ -24,6 +24,12 @@ Attach to a remote tmux over SSH: ssh darth.local -t "/opt/homebrew/bin/tmux attach" ``` +Use `tmux-ssh` to SSH into a host and attach to (or create) a tmux session: +```sh +tmux-ssh kylo +tmux-ssh 192.168.86.201 +``` + ## Windows | Key | Action | diff --git a/files/shell/functions/tmux-ssh b/files/shell/functions/tmux-ssh index ce69a7b..b3bd677 100644 --- a/files/shell/functions/tmux-ssh +++ b/files/shell/functions/tmux-ssh @@ -1,7 +1,7 @@ -tmux-ssh() { +function tmux-ssh() { if [[ -z "${1:-}" ]]; then - print "Usage: tmux-ssh " + echo "Usage: tmux-ssh " return 1 fi - ssh -t "$1" 'tmux attach || tmux new-session' + ssh "$1" -t "tmux new-session -A -s main" } From 19402e0569db2f047d58016cc38225a906754763 Mon Sep 17 00:00:00 2001 From: Jan Groth Date: Mon, 4 May 2026 21:15:19 +1000 Subject: [PATCH 3/5] Add tmux-ssh function to SSH into host and attach/create tmux session Closes #50 --- README.md | 2 +- files/help/tmux | 7 +------ files/shell/functions/tmux-ssh | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e4511bc..a9cd50a 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ make install - `pro [path]` — jump to a project directory under `$PROJECTS_HOME` (`~/Projects` on macOS, `~` on Linux), with tab completion for nested paths - `dfh [topic]` — dotfiles help; run `dfh` for version info and available topics, `dfh tmux` / `dfh fzf` / `dfh vim` for keybinding references extracted from config files -- `tmux-ssh ` — SSH into a host and attach to an existing tmux session (or create one named `main`) +- `tmux-ssh ` — SSH into a host and attach to an existing tmux session (named `main`) or create one if none exists diff --git a/files/help/tmux b/files/help/tmux index 2a61e90..04dfa43 100644 --- a/files/help/tmux +++ b/files/help/tmux @@ -19,12 +19,7 @@ Within the session list (`prefix + s`): `x` to delete, `t` to tag. -Attach to a remote tmux over SSH: -```sh -ssh darth.local -t "/opt/homebrew/bin/tmux attach" -``` - -Use `tmux-ssh` to SSH into a host and attach to (or create) a tmux session: +Attach to a remote tmux over SSH (attach existing session or create new): ```sh tmux-ssh kylo tmux-ssh 192.168.86.201 diff --git a/files/shell/functions/tmux-ssh b/files/shell/functions/tmux-ssh index b3bd677..d33c5a2 100644 --- a/files/shell/functions/tmux-ssh +++ b/files/shell/functions/tmux-ssh @@ -1,7 +1,7 @@ -function tmux-ssh() { +tmux-ssh() { if [[ -z "${1:-}" ]]; then - echo "Usage: tmux-ssh " + print "Usage: tmux-ssh " return 1 fi - ssh "$1" -t "tmux new-session -A -s main" + ssh -t "$1" "tmux new-session -A -s main" } From cb78a814641da354e04e1255810c7a6e6c4878fb Mon Sep 17 00:00:00 2001 From: Jan Groth Date: Tue, 5 May 2026 21:12:52 +1000 Subject: [PATCH 4/5] =?UTF-8?q?Add=20tmux-ssh=20function=20=E2=80=94=20SSH?= =?UTF-8?q?=20into=20host=20and=20attach=20or=20create=20tmux=20session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements the function described in issue #50. Uses `tmux new-session -A -s main` so it attaches to an existing session named 'main' if one exists, otherwise creates a new one. Updates README and the dfh tmux help page accordingly. Closes #50 --- README.md | 2 +- files/help/tmux | 4 ++-- files/shell/functions/tmux-ssh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a9cd50a..43ddcd6 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ make install - `pro [path]` — jump to a project directory under `$PROJECTS_HOME` (`~/Projects` on macOS, `~` on Linux), with tab completion for nested paths - `dfh [topic]` — dotfiles help; run `dfh` for version info and available topics, `dfh tmux` / `dfh fzf` / `dfh vim` for keybinding references extracted from config files -- `tmux-ssh ` — SSH into a host and attach to an existing tmux session (named `main`) or create one if none exists +- `tmux-ssh ` — SSH into a machine and attach to (or create) a tmux session named `main` diff --git a/files/help/tmux b/files/help/tmux index 04dfa43..cb61041 100644 --- a/files/help/tmux +++ b/files/help/tmux @@ -19,7 +19,7 @@ Within the session list (`prefix + s`): `x` to delete, `t` to tag. -Attach to a remote tmux over SSH (attach existing session or create new): +Attach to (or create) a tmux session on a remote machine: ```sh tmux-ssh kylo tmux-ssh 192.168.86.201 @@ -39,7 +39,7 @@ tmux-ssh 192.168.86.201 ## Panes | Key | Action | -|--------------------|-----------------------------------------| +|--------------------|------------------------------------------| | `prefix + \|` | Split horizontally (keeps current path) | | `prefix + -` | Split vertically (keeps current path) | | `prefix + h/j/k/l` | Move between panes (vi-style) | diff --git a/files/shell/functions/tmux-ssh b/files/shell/functions/tmux-ssh index d33c5a2..be6177d 100644 --- a/files/shell/functions/tmux-ssh +++ b/files/shell/functions/tmux-ssh @@ -1,6 +1,6 @@ tmux-ssh() { if [[ -z "${1:-}" ]]; then - print "Usage: tmux-ssh " + echo "Usage: tmux-ssh " return 1 fi ssh -t "$1" "tmux new-session -A -s main" From 699109a1190a7055f74aa7dc9a6ec663a86d9427 Mon Sep 17 00:00:00 2001 From: Jan Groth Date: Thu, 7 May 2026 21:08:54 +1000 Subject: [PATCH 5/5] Add tmux-ssh function for SSH with tmux session attach SSHes into the given host and attaches to (or creates) a tmux session named 'main', using `tmux new-session -A -s main`. Closes #50 --- files/shell/functions/tmux-ssh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/files/shell/functions/tmux-ssh b/files/shell/functions/tmux-ssh index be6177d..715949f 100644 --- a/files/shell/functions/tmux-ssh +++ b/files/shell/functions/tmux-ssh @@ -1,7 +1,4 @@ tmux-ssh() { - if [[ -z "${1:-}" ]]; then - echo "Usage: tmux-ssh " - return 1 - fi - ssh -t "$1" "tmux new-session -A -s main" + local host="${1:?Usage: tmux-ssh }" + ssh -t "$host" 'tmux new-session -A -s main' }