diff --git a/shrc b/shrc index 9a4fcf1..f2ed1f0 100755 --- a/shrc +++ b/shrc @@ -665,15 +665,18 @@ __realpath(){ tx(){ tmux start-server - if test $# -eq 0 + if test -z "$1" then - echo ":: tx to attach." - tmux ls - elif tmux has -t "$1" + echo "usage: tx " + tmux list-sessions + elif test -z "$TMUX" then - tmux attach -t "$1" + # -A: attach if already exists + tmux new-session -A -c "$HOME" -s "$1" else - tmux new -s "$1" + # create new session if not exists yet + tmux has-session -t "$1" || TMUX= tmux new-session -d -c "$HOME" -s "$1" + tmux switch-client -t "$1" fi }