diff options
| author | tv <tv@nomic.retiolum> | 2013-12-30 14:47:53 +0100 |
|---|---|---|
| committer | tv <tv@nomic.retiolum> | 2013-12-30 14:47:53 +0100 |
| commit | 2924760337fa6f5ecc64df99f4e022b0b7965c4f (patch) | |
| tree | d1158b010d3668a3681274bde494ae8e82ce5c8e /bridge/lib | |
| parent | db8fd88a4f8bd4e82b4977ceb9d033b44cfcf13c (diff) | |
| parent | 08aa5e406a1f7b39182e79ea4eb7fabf7d61eaa3 (diff) | |
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'bridge/lib')
| -rwxr-xr-x | bridge/lib/bridge/bin/attach | 10 | ||||
| -rwxr-xr-x | bridge/lib/bridge/bin/create | 15 | ||||
| -rwxr-xr-x | bridge/lib/bridge/bin/destroy | 12 | ||||
| -rwxr-xr-x | bridge/lib/bridge/bin/list | 10 | ||||
| -rwxr-xr-x | bridge/lib/bridge/bin/paste | 30 |
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. |
