aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/tmux.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-02 00:24:39 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-02 00:24:39 +1200
commitef9a12e780efdd1eb0ddcb745b9d93e312353b73 (patch)
tree52672882a2f8c89cd76ef5df0ef706e8bbb933d5 /bash/bashrc.d/tmux.bash
parentTerser pa/paz implementations (diff)
downloaddotfiles-ef9a12e780efdd1eb0ddcb745b9d93e312353b73.tar.gz
dotfiles-ef9a12e780efdd1eb0ddcb745b9d93e312353b73.zip
Use set rather than building arg arrays
Allows for terser functions and avoids error-prone local variables; also nicer to have a single `command` call at the end of the function (although there are still two at the end of the ed(1) wrapper)
Diffstat (limited to 'bash/bashrc.d/tmux.bash')
-rw-r--r--bash/bashrc.d/tmux.bash9
1 files changed, 6 insertions, 3 deletions
diff --git a/bash/bashrc.d/tmux.bash b/bash/bashrc.d/tmux.bash
index c70a7908..f0d0e36a 100644
--- a/bash/bashrc.d/tmux.bash
+++ b/bash/bashrc.d/tmux.bash
@@ -3,14 +3,17 @@ tmux() {
# If given any arguments, just use them as they are
if (($#)) ; then
- command tmux "$@"
+ :
# If a session exists, just attach to it
elif command tmux has-session 2>/dev/null ; then
- command tmux attach-session -d
+ set -- attach-session -d
# Create a new session with an appropriate name
else
- command tmux new-session -s "${TMUX_SESSION:-default}"
+ set -- new-session -s "${TMUX_SESSION:-default}"
fi
+
+ # Execute with concluded arguments
+ command tmux "$@"
}