summaryrefslogtreecommitdiffstats
path: root/bridge/lib
diff options
context:
space:
mode:
authormakefu <root@pigstarter.de>2013-12-30 14:34:38 +0100
committermakefu <root@pigstarter.de>2013-12-30 14:34:38 +0100
commit08aa5e406a1f7b39182e79ea4eb7fabf7d61eaa3 (patch)
tree2db1a54f336167cc3cc3d5f74c77d029fe7e7470 /bridge/lib
parent133e49566c74f1d21c28536ed31d1514725ed49b (diff)
//Cancer -> //
because that is what painload is all about
Diffstat (limited to 'bridge/lib')
-rwxr-xr-xbridge/lib/bridge/bin/attach10
-rwxr-xr-xbridge/lib/bridge/bin/create15
-rwxr-xr-xbridge/lib/bridge/bin/destroy12
-rwxr-xr-xbridge/lib/bridge/bin/list10
-rwxr-xr-xbridge/lib/bridge/bin/paste30
5 files changed, 77 insertions, 0 deletions
diff --git a/bridge/lib/bridge/bin/attach b/bridge/lib/bridge/bin/attach
new file mode 100755
index 00000000..f456f8a6
--- /dev/null
+++ b/bridge/lib/bridge/bin/attach
@@ -0,0 +1,10 @@
+#! /bin/sh
+#
+# Attach current tty to a session.
+#
+## SYNOPSIS
+#
+# bridge attach SESSION
+#
+set -euf
+exec tmux -L bridge attach-session -t "$1"
diff --git a/bridge/lib/bridge/bin/create b/bridge/lib/bridge/bin/create
new file mode 100755
index 00000000..2df8b214
--- /dev/null
+++ b/bridge/lib/bridge/bin/create
@@ -0,0 +1,15 @@
+#! /bin/sh
+#
+# Create a new session.
+#
+## SYNOPSIS
+#
+# bridge create SESSION [COMMAND [ARGS ...]]
+#
+# COMMAND defaults to $SHELL (by implication / tmux)
+#
+set -euf
+target="$1"; shift
+tmux -L bridge new-session -d -s "$target" "$@"
+tmux -L bridge set-buffer READY.
+exec "$(dirname $0)/attach" "$target"
diff --git a/bridge/lib/bridge/bin/destroy b/bridge/lib/bridge/bin/destroy
new file mode 100755
index 00000000..dffdbd8a
--- /dev/null
+++ b/bridge/lib/bridge/bin/destroy
@@ -0,0 +1,12 @@
+#! /bin/sh
+#
+# Destroy a session.
+#
+## SYNOPSIS
+#
+# bridge destroy SESSION
+#
+# Note that this may destroy similar named sessions (by implication / tmux)
+#
+set -euf
+tmux -L bridge kill-session -t "$1"
diff --git a/bridge/lib/bridge/bin/list b/bridge/lib/bridge/bin/list
new file mode 100755
index 00000000..0b767a9b
--- /dev/null
+++ b/bridge/lib/bridge/bin/list
@@ -0,0 +1,10 @@
+#! /bin/sh
+#
+# Write a list of all session names to stdout.
+#
+## SYNOPSIS
+#
+# bridge list
+#
+set -euf
+exec tmux -L bridge list-sessions | cut -d: -f1
diff --git a/bridge/lib/bridge/bin/paste b/bridge/lib/bridge/bin/paste
new file mode 100755
index 00000000..d3ed1fc5
--- /dev/null
+++ b/bridge/lib/bridge/bin/paste
@@ -0,0 +1,30 @@
+#! /bin/sh
+#
+# Paste some data to a session.
+#
+## SYNOPSIS
+#
+# bridge paste SESSION DATA...
+# bridge paste SESSION < DATA
+#
+set -euf
+
+target="$1"; shift
+
+# paste args or stdin
+if test $# -gt 0; then
+ tmux -L bridge set-buffer -b 0 "$*"
+else
+ # use aux file instead of direct stdin for Vim and when used from $SHELL
+ if test -n "${VIMRUNTIME-}" || tty >/dev/null; then
+ path=`mktemp`
+ trap "rm -f $path" EXIT INT TERM
+ cat>$path
+ else
+ path=-
+ fi
+ tmux -L bridge load-buffer -b 0 $path
+fi
+
+tmux -L bridge paste-buffer -b 0 -t "$target"
+tmux -L bridge set-buffer -b 0 READY.