From e766d9fe1d0c5677214a0a100edf43e7056d7662 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sat, 17 Aug 2013 22:16:13 +0200 Subject: initial commit --- bin/copy | 14 ++++++++++++++ bin/t | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 bin/copy create mode 100755 bin/t (limited to 'bin') diff --git a/bin/copy b/bin/copy new file mode 100755 index 0000000..68d10ca --- /dev/null +++ b/bin/copy @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [[ -z "$1" ]] ; then + echo "Usage:" + echo -en "\t" + echo "$(basename $0) " + exit 1 +fi + +# encode files suitable for copy&paste into other terminals +STR=$(tar cjf - "$@" | base64; exit $PIPESTATUS) || exit $? +echo "cat << E=O=F | base64 -d | tar xj" +echo "$STR" +echo "E=O=F" diff --git a/bin/t b/bin/t new file mode 100755 index 0000000..c6a1be3 --- /dev/null +++ b/bin/t @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +real_tmux() { + if [ -n "${REMOTE_USER}" -a -e "${HOME}/.${REMOTE_USER}/tmux/tmux.conf" ]; then + \tmux -f "${HOME}/.${REMOTE_USER}/tmux/tmux.conf" -S "${HOME}/.${REMOTE_USER}/tmux/socket" "$@" + else + \tmux "$@" + fi +} + +exec_real_tmux() { + if [ -n "${REMOTE_USER}" -a -e "${HOME}/.${REMOTE_USER}/tmux/tmux.conf" ]; then + exec \tmux -f "${HOME}/.${REMOTE_USER}/tmux/tmux.conf" -S "${HOME}/.${REMOTE_USER}/tmux/socket" "$@" + else + exec \tmux "$@" + fi +} + +if [[ "x$1" == x ]] ; then + real_tmux list-sessions || + { + real_tmux new-session -d + } + + exec_real_tmux attach-session -d +fi + +if [ -z "$2" -a "$1" != "att" -a "$1" != "ls" ]; then + if real_tmux has-session -t "$1"; then + exec_real_tmux attach-session -t "$1" + else + exec_real_tmux new-session -s "$1" + fi +fi + +exec_real_tmux $@ -- cgit v1.2.3-1-g7c22