Add ssh:// support. Cut, cut, cut ... - plumber - Plumber – a modern approach to plumbing
Log
Files
Refs
LICENSE
---
commit 697ce9b14111d7caa5a13e57b78eca50a0b6d130
parent d964dfaee960f19da5185f8ac04ef0eaafc00f14
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun,  2 Apr 2017 08:48:20 +0200

Add ssh:// support. Cut, cut, cut ...

Diffstat:
  bin/plumber                         |       1 +
  openers/danceopener                 |      10 ++++++++++
  openers/sshopener                   |      33 +++++++++++++++++++++++++++++++

3 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/bin/plumber b/bin/plumber
@@ -57,6 +57,7 @@ plumbrules = [
         ["^rtsp://.*", "mediaopener '%s'"],
         ["^udp://.*", "mediaopener '%s'"],
         ["^telnet(s|)(4|6|)://.*", "telnetopener '%s'"],
+        ["^ssh://.*", "sshopener '%s'"],
         ["^tv://.*", "tvopener '%s'"],
         ["^yt://.*", "ytopener '%s'"],
         ["^youtube://.*", "ytopener '%s'"],
diff --git a/openers/danceopener b/openers/danceopener
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ $# -lt 1 ];
+tthen
+        printf "usage: %s URI\n" "$(basename "$0")" >&2
+        exit 1
+fi
+
+st -ig =6x7 dance
+
diff --git a/openers/sshopener b/openers/sshopener
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -x
+
+if [ $# -lt 1 ];
+tthen
+        printf "usage: %s URI\n" "$(basename "$0")" >&2
+        exit 1
+fi
+
+uri="$1"
+
+# »cut, cut, cut, ...« makes the chicken.
+host="$(printf "%s\n" "$uri" \
+        | cut -d ':' -f 2- \
+        | cut -c 3- \
+        | cut -d':' -f 1 \
+        | cut -d'/' -f 1)"
+
+# »cut, cut, cut, ...« makes the turkey.
+port="$(printf "%s\n" "$uri" \
+        | cut -d ':' -f 2- \
+        | cut -c 3- \
+        | cut -s -d':' -f 2- \
+        | cut -d '/' -f 1)"
+t[ -z "$port" ] && port="22"
+
+st -e sh -c \
+        "printf \"URI: %s\n\" "${uri}"; \
+         ssh -p \"${port}\" \"${host}\"; \
+         read;" \
+         2>&1 >/dev/null &
+