diff --git a/.config/systemd/user/opener@.service b/.config/systemd/user/opener@.service new file mode 100644 index 0000000..ae713c9 --- /dev/null +++ b/.config/systemd/user/opener@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Open URL in your local web browser from the SSH-connected remote environment. + +[Service] +Restart=always +Environment=OPENER_CONF=%t/opener.%i.conf +ExecStart=/bin/sh -c 'echo "address: %t/opener.%i.sock" > $OPENER_CONF && exec %h/bin/opener --config $OPENER_CONF' + +[Install] +WantedBy=graphical-session.target diff --git a/.ssh/config b/.ssh/config index df495cf..8b147e7 100644 --- a/.ssh/config +++ b/.ssh/config @@ -21,6 +21,7 @@ LocalForward 127.0.0.1:3000 127.0.0.1:3000 LocalForward 127.0.0.1:8000 127.0.0.1:8000 LocalForward 127.0.0.1:8080 127.0.0.1:8080 LocalForward 127.0.0.1:9090 127.0.0.1:9090 +RemoteForward ${XDG_RUNTIME_DIR}/opener.sock ${XDG_RUNTIME_DIR}/opener.dln-dev.sock Host * ForwardAgent no diff --git a/bin/xdg-open b/bin/xdg-open new file mode 100755 index 0000000..1a10b0b --- /dev/null +++ b/bin/xdg-open @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -eu + +# Use local xdg-open if not in an ssh session +[ -n "$SSH_TTY" ] || exec /usr/bin/xdg-open "$@" + +if [ -p /dev/stdin ]; then + exec nc -U "$XDG_RUNTIME_DIR/opener.sock"