diff options
-rw-r--r-- | ssh/.config/profile.d/99-ssh-open.sh | 5 | ||||
-rwxr-xr-x | ssh/.local/bin/ssh-open | 8 | ||||
-rwxr-xr-x | tmux/.local/bin/tmux-sshr | 7 |
3 files changed, 17 insertions, 3 deletions
diff --git a/ssh/.config/profile.d/99-ssh-open.sh b/ssh/.config/profile.d/99-ssh-open.sh new file mode 100644 index 0000000..77ac11f --- /dev/null +++ b/ssh/.config/profile.d/99-ssh-open.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CLIENT" ]; then + export BROWSER="ssh-open" +fi diff --git a/ssh/.local/bin/ssh-open b/ssh/.local/bin/ssh-open new file mode 100755 index 0000000..276360c --- /dev/null +++ b/ssh/.local/bin/ssh-open @@ -0,0 +1,8 @@ +#!/usr/bin/sh + +HOSTNAME=$(uname -n) + +printf '%s' "$1" | sed \ + -e "s/localhost/$HOSTNAME/" \ + -e "s/127\(\.[0-9]\{1,3\}\)\{3\}/$HOSTNAME/" | + xargs -I{} ssh -l "$USER" -p 2222 localhost "xdg-open '{}'" diff --git a/tmux/.local/bin/tmux-sshr b/tmux/.local/bin/tmux-sshr index 7120703..42618ad 100755 --- a/tmux/.local/bin/tmux-sshr +++ b/tmux/.local/bin/tmux-sshr @@ -27,8 +27,8 @@ if [ "$target" = "$HOST" ]; then tmux detach -E 'tmux new -A' else if ! tmux -L ssh has-session -t "$target"; then - local_socket=$(tmux -L ssh start-server \; display -p "#{socket_path}") - remote_socket=$( + tmux_local_sock=$(tmux -L ssh start-server \; display -p "#{socket_path}") + tmux_remote_sock=$( ssh -T \ -o "ControlMaster=auto" \ -o "ControlPath=${XDG_RUNTIME_DIR}/ssh.%C" \ @@ -39,7 +39,8 @@ else ssh -t \ -o "ControlMaster=auto" \ -o "ControlPath=${XDG_RUNTIME_DIR}/ssh.%C" \ - -R "$local_socket":"$remote_socket" \ + -R "2222:localhost:22" \ + -R "$tmux_remote_sock:$tmux_local_sock" \ "$target" "zsh -l -c 'tmux new -A'" fi |