diff options
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. |