aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/tmux.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-09-28 13:46:14 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-09-28 13:46:14 +1300
commit4394b20ff29f5c8346d1676c8e8c8717d4de29b7 (patch)
treec32f4436f4e140ac39d441da7db34d58e35a3d84 /bash/bashrc.d/tmux.bash
parentUpdate plugins (diff)
downloaddotfiles-4394b20ff29f5c8346d1676c8e8c8717d4de29b7.tar.gz
dotfiles-4394b20ff29f5c8346d1676c8e8c8717d4de29b7.zip
Allow specifying default tmux session name
Also restructure so only one explicit call to tmux command
Diffstat (limited to 'bash/bashrc.d/tmux.bash')
-rw-r--r--bash/bashrc.d/tmux.bash14
1 files changed, 11 insertions, 3 deletions
diff --git a/bash/bashrc.d/tmux.bash b/bash/bashrc.d/tmux.bash
index 50a45ee2..241af526 100644
--- a/bash/bashrc.d/tmux.bash
+++ b/bash/bashrc.d/tmux.bash
@@ -5,14 +5,22 @@ fi
# Attach to existing tmux session rather than create a new one if possible
tmux() {
+ local -a tcmd
# If sessions exist, default the arguments to the attach-session command
- if ! (($#)) && command tmux has-session 2>/dev/null ; then
- command tmux attach-session -d
+ if ! (($#)) ; then
+ if command tmux has-session 2>/dev/null ; then
+ tcmd=(attach-session -d)
+ else
+ tcmd=(new-session -s "${TMUX_SESSION:-default}")
+ fi
# Otherwise, just call tmux directly with the given arguments
else
- command tmux "$@"
+ tcmd=("$@")
fi
+
+ # Run tmux command with concluded arguments
+ command tmux "${tcmd[@]}"
}