diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-08-17 22:16:13 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-08-17 22:16:13 +0200 |
commit | e766d9fe1d0c5677214a0a100edf43e7056d7662 (patch) | |
tree | eb93e10c81714e8ea7dd826fbcd7d217ced1dc87 /bin | |
download | dotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.tar.gz dotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.tar.bz2 dotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.zip |
initial commit
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/copy | 14 | ||||
-rwxr-xr-x | bin/t | 36 |
2 files changed, 50 insertions, 0 deletions
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) <files/directories>" + 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" @@ -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 $@ |