2011
01.26

tmux bashrc snippet

so on most of my machines i have mrxvt to be my primary term in evilwm. every time i do the term hotkey i want a new session of tmux to start up without attaching to a previous / existing session.

here is what i added in my .bashrc to make this happen:

tmux_count=`tmux ls | wc -l`
if [[ "$tmux_count" == "0" ]]; then
    tmux -2
else
    if [[ -z "$TMUX" ]]; then
        if [[ "$tmux_count" == "1" ]]; then
            session_id=1
        else
            session_id=`echo $tmux_count`
        fi
    tmux new-session -d -s $session_id
    tmux attach-session -t $session_id
    fi
fi

this snippit will also increase your tmux session id’s by one each time and not attach to an existing session id.

The following two tabs change content below.

Latest posts by cesar (see all)

No Comment.

Add Your Comment