diff options
Diffstat (limited to 'ssh/.local/bin/ssh-open')
-rwxr-xr-x | ssh/.local/bin/ssh-open | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ssh/.local/bin/ssh-open b/ssh/.local/bin/ssh-open index 276360c..01b650c 100755 --- a/ssh/.local/bin/ssh-open +++ b/ssh/.local/bin/ssh-open @@ -1,8 +1,15 @@ #!/usr/bin/sh -HOSTNAME=$(uname -n) +if [ -n "$SSH_CLIENT" ]; then + 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 '{}'" + printf '%s' "$@" | + sed -e "s/localhost/$HOSTNAME/" -e "s/127\(\.[0-9]\{1,3\}\)\{3\}/$HOSTNAME/" | + if [ -S "$XDG_RUNTIME_DIR"/xdg-open.socket ] && command -v nc >/dev/null; then + nc -UN "$XDG_RUNTIME_DIR"/xdg-open.socket + else + xargs -I{} ssh -l "$USER" -p 2222 localhost "xdg-open '{}'" + fi +else + $(command -vp xdg-open) "$@" +fi |