aboutsummaryrefslogblamecommitdiff
path: root/bash/bashrc.d/tmux.bash
blob: 50a45ee2d241f64ef79710ea9c3bd85e21ccc51c (plain) (tree)
1
2
3
4
5
6
7
8
9
                    
                                 


          
                                                                          
        
 
                                                                            
                                                              
                                      
 


                                                                 


      
# Bail if no tmux(1)
if ! hash tmux 2>/dev/null ; then
    return
fi

# Attach to existing tmux session rather than create a new one if possible
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 -d

    # Otherwise, just call tmux directly with the given arguments
    else
        command tmux "$@"
    fi
}