From 064d0757479ddf5da3cab8075d2e2ed99d861d71 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 26 Apr 2023 19:47:34 -0500 Subject: fix(tmux): fix hardcoded tmux socket path --- tmux/.local/bin/tmux-ssh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tmux/.local/bin/tmux-ssh') diff --git a/tmux/.local/bin/tmux-ssh b/tmux/.local/bin/tmux-ssh index 470368b..a0f838b 100755 --- a/tmux/.local/bin/tmux-ssh +++ b/tmux/.local/bin/tmux-ssh @@ -27,10 +27,20 @@ if [ "$target" = "$HOST" ]; then tmux detach -E 'tmux new -A' else if ! tmux -L ssh has-session -t "$target"; then - # TODO: figure out how to get the remote user id (or $XDG_RUNTIME_DIR), *before* initial - # connection, in order to map to other user id's. + local_socket=$(tmux -L ssh start-server \; display -p "#{socket_path}") + remote_socket=$( + ssh -T \ + -o "ControlMaster=auto" \ + -o "ControlPath=${XDG_RUNTIME_DIR}/ssh.%C" \ + "$target" 'tmux -L ssh start-server \; display -p "#{socket_path}"' + ) + tmux -L ssh new-session -ds "$target" \ - ssh -t -R /tmp/tmux-1000/ssh:/tmp/tmux-1000/ssh "$target" "zsh -l -c 'tmux new -A'" + ssh -t \ + -o "ControlMaster=auto" \ + -o "ControlPath=${XDG_RUNTIME_DIR}/ssh.%C" \ + -R "$local_socket":"$remote_socket" \ + "$target" "zsh -l -c 'tmux new -A'" fi if [ -z "$TMUX" ]; then -- cgit v1.2.3-70-g09d2