summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-08-17 22:16:13 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-08-17 22:16:13 +0200
commite766d9fe1d0c5677214a0a100edf43e7056d7662 (patch)
treeeb93e10c81714e8ea7dd826fbcd7d217ced1dc87 /bin
downloaddotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.tar.gz
dotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.tar.bz2
dotfiles-mini-e766d9fe1d0c5677214a0a100edf43e7056d7662.zip
initial commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/copy14
-rwxr-xr-xbin/t36
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"
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 $@