From 787a747f6f374434890e73430fae9899d76c38e5 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 14 Apr 2014 20:29:32 +0200 Subject: tmux: config and socket in dofiles directory --- bashrc/bin/t | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'bashrc') diff --git a/bashrc/bin/t b/bashrc/bin/t index 019eda9..3919af4 100755 --- a/bashrc/bin/t +++ b/bashrc/bin/t @@ -1,12 +1,37 @@ #!/usr/bin/env bash +real_tmux() { + if [ -f "${HOME}/.dotfiles/tmux/tmux.conf" ]; then + \tmux -f "${HOME}/.dotfiles/tmux/tmux.conf" -S "${HOME}/.dotfiles/tmux/socket" "$@" + else + \tmux "$@" + fi +} + +exec_real_tmux() { + if [ -f "${HOME}/.dotfiles/tmux/tmux.conf" ]; then + exec \tmux -f "${HOME}/.dotfiles/tmux/tmux.conf" -S "${HOME}/.dotfiles/tmux/socket" "$@" + else + exec \tmux "$@" + fi +} + + if [[ "x$1" == x ]] ; then - \tmux list-sessions || + real_tmux list-sessions || { - \tmux new-session -d + real_tmux new-session -d } - exec \tmux attach-session -d + exec_real_tmux attach-session -d +fi + +if [ -z "$2" -a "$1" != "att" -a "$1" != "ls" ]; then + if teal_tmux has-session -t "$1"; then + exec exec_real_tmux attach-session -t "$1" + else + exec exec_real_tmux new-session -s "$1" + fi fi -exec \tmux $@ +exec_real_tmux $@ -- cgit v1.2.3