Skip to content

How to optimally start *tmux* in every Termux session? #4123

Closed Answered by sylirre
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

~/.zlogin specific to zsh shell but default shell of Termux is bash. It uses ~/.bash_profile, in this file you can add:

# Don't run code below if shell is non-interactive
[[ $- != *i* ]] && return

# Start tmux if not running already in current shell session.
if [ -z "$TMUX" ]; then
    exec tmux
fi

If you want all Termux sessions to share single tmux instance use this instead:

# Don't run code below if shell is non-interactive
[[ $- != *i* ]] && return

# If not already under tmux, try attaching to existing instance. If no tmux instance exist, start new.
if [ -z "$TMUX" ]; then
    tmux attach 2>/dev/null || tmux
    exit
fi

Side effect of using single tmux instance: ctrl-d will termin…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant