How to launch tmux –automatically– when konsole/yakuake start?

A friend advice to use <terminal_emulator> -e tmux.

Konsole

It works with konsole.

I modified the property in the menu to:

konsole -e tmux

Yakuake

However it doesn't work with yakuake.


Based on Start tmux on every shell login article from Archlinux wiki, you can start tmux on your shell with following code at the

Zsh or Bash

Add in your zsh or bash configuration (usually ~/.zshrc or ~/.bashrc) the following code and restart your session:

function start_tmux() {
    if type tmux &> /dev/null; then
        #if not inside a tmux session, and if no session is started, start a new session
        if [[ $HOST == "laptop" && -z "$TMUX" && -z $TERMINAL_CONTEXT ]]; then
            (tmux -2 attach || tmux -2 new-session)
        fi
    fi
}
start_tmux

Fish

Add in your fish configuration (usually ~/.config/fish/config.fish) the following code and restart your session:

function start_tmux
    if type tmux > /dev/null
        #if not inside a tmux session, and if no session is started, start a new session
        if test -z "$TMUX" ; and test -z $TERMINAL_CONTEXT
            tmux -2 attach; or tmux -2 new-session
        end
    end
end

start_tmux