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

                                                                     
                       
                         



                                                                               




                                                          
# 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 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
    else
        command tmux attach -d &>/dev/null || command tmux
    fi
}