From bfbbef4a08e506eb61d232b2fcfb5f480a0c5a0e Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sun, 8 Dec 2019 16:07:12 +0200
Subject: [PATCH] Control output from docker-remote.

So now I can run `$(eval docker remote hostname)`.
---
 Documents/bin/_docker-remote | 5 ++---
 Documents/bin/forward        | 6 +++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Documents/bin/_docker-remote b/Documents/bin/_docker-remote
index cb0cf54..423d7f2 100755
--- a/Documents/bin/_docker-remote
+++ b/Documents/bin/_docker-remote
@@ -1,13 +1,12 @@
 #!/bin/sh
 set -eu
 
-
 [ -n "$1" ] || { echo "You must specify host." >&2; exit 1; }
 host="$1"
 localsocket="$HOME/.ssh/docker_$host.sock"
 
-lsof -t "$localsocket" > /dev/null || rm "$localsocket"
-forward "$host" "$localsocket:/var/run/docker.sock"
+lsof -t "$localsocket" > /dev/null 2>&1 || rm -f "$localsocket"
+forward "$host" "$localsocket:/var/run/docker.sock" > /dev/null 2>&1
 
 # Echo the DOCKER_HOST export command, for eval'ing.
 echo "export DOCKER_HOST=unix://$localsocket"
diff --git a/Documents/bin/forward b/Documents/bin/forward
index d648670..a75ecd7 100755
--- a/Documents/bin/forward
+++ b/Documents/bin/forward
@@ -10,6 +10,10 @@ forward="$2" || { usage >&2; exit 1; }
 alias ssh='ssh -fnNTS ~/.ssh/%C.sock'
 
 # shellcheck disable=SC2029
-ssh -o ControlMaster=auto -o ControlPersist=0 -o ExitOnForwardFailure=no -o ControlPersist=0 "$host"
+ssh -o ControlMaster=auto \
+    -o ControlPersist=0 \
+    -o ExitOnForwardFailure=no \
+    -o ControlPersist=0 \
+    "$host"
 # shellcheck disable=SC2029
 ssh -O forward -L "$forward" "$host"
-- 
GitLab