summaryrefslogtreecommitdiffstats
path: root/util/bin
diff options
context:
space:
mode:
authorChinaman <root@chinaman>2011-11-29 02:00:09 +0100
committerChinaman <root@chinaman>2011-11-29 02:00:09 +0100
commita95cb58ffa45cf2f25430592a7cc60b70e26f232 (patch)
tree0a3317106bba36b736e1dc0611ee25fa9a0cf4aa /util/bin
parenta7c3985212df3b1c3599fe50d0542883d69ae1c6 (diff)
//util sshkill: initial commit
Diffstat (limited to 'util/bin')
-rwxr-xr-xutil/bin/sshkill33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/bin/sshkill b/util/bin/sshkill
new file mode 100755
index 00000000..80300483
--- /dev/null
+++ b/util/bin/sshkill
@@ -0,0 +1,33 @@
+#! /bin/sh
+#
+# kill ssh client: sshkill user@host:port
+# setup bash completion: . sshkill
+#
+if ! grep -q '^ControlPath /tmp/%u/sshmux/%r@%h:%p$' "$HOME/.ssh/config"; then
+ echo "Your ~/.ssh/config's ControlPath sucks!" >&2
+ (exit 23)
+else
+ if test "${0:0:1}" = -; then
+ if ! echo "${BASHOPTS-}" | grep -Eq '(^|:)progcomp(:|$)'; then
+ echo "source sshmux into something other than a progcomp'able bash" >&2
+ (exit 23)
+ else
+
+ # setup bash completion
+ comp_sshkill() {
+ if test $COMP_CWORD = 1; then
+ COMPREPLY=($(cd "/tmp/$LOGNAME/sshmux" &&
+ ls | grep "^${COMP_WORDS[$COMP_CWORD]}.*"))
+ fi
+ }
+ complete -F comp_sshkill sshkill
+
+ fi
+ else
+
+ # kill ssh client
+ set -euf
+ exec pkill -f "^ssh: /tmp/$LOGNAME/sshmux/$1 \[mux\]$"
+
+ fi
+fi