diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-14 12:51:22 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-14 12:51:22 +1200 |
commit | 6a5c3c3cf074fec95b2ad9701703577cec2a60a9 (patch) | |
tree | 9659469dcf3336b1914965de35bf4ea6f68ea350 /bash | |
parent | Add ''ll'' alias for ''ls -al'' (diff) | |
download | dotfiles-6a5c3c3cf074fec95b2ad9701703577cec2a60a9.tar.gz dotfiles-6a5c3c3cf074fec95b2ad9701703577cec2a60a9.zip |
Use tidier default system for tmux function
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/tmux.bash | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bash/bashrc.d/tmux.bash b/bash/bashrc.d/tmux.bash index 1a160790..f4b42081 100644 --- a/bash/bashrc.d/tmux.bash +++ b/bash/bashrc.d/tmux.bash @@ -1,15 +1,13 @@ # Attach to existing tmux session rather than create a new one if possible tmux() { - # If any arguments to function, just run tmux as normal with them - if (($# > 0)); then - command tmux "$@" + # If sessions exist, default the arguments to the attach-session command + if command tmux has-session 2>/dev/null; then + command tmux "${@:-attach-session}" - # If no arguments, attempt to attach to an existing session; if that fails, - # run the tmux binary with no arguments, which by default creates a new - # session - elif ! command tmux attach -d 2>/dev/null; then - command tmux + # Otherwise, just call tmux directly with the given arguments + else + command tmux "$@" fi } |