diff options
author | Toby Vincent <tobyv13@gmail.com> | 2023-04-26 19:47:34 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2023-04-26 19:47:34 -0500 |
commit | 064d0757479ddf5da3cab8075d2e2ed99d861d71 (patch) | |
tree | fca0cbc1bf51b4219f88d424b648ee3b483a9cdd /tmux | |
parent | 9e3e6e0fb387f284795e9cd1c96f8a6a45f38f1f (diff) |
fix(tmux): fix hardcoded tmux socket path
Diffstat (limited to 'tmux')
-rwxr-xr-x | tmux/.local/bin/tmux-ssh | 16 |
1 files changed, 13 insertions, 3 deletions
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 |