如何在 konsole/yakuake 启动时自动启动 tmux?

Édo*_*pez 7 terminal konsole tmux yakuake

tmux最近发现了可能性,我在yakuake/ konsole(类似地震的终端)中使用它。但是,tmux每次启动笔记本电脑或重新启动时,我都必须手动启动yakuake

如何启动tmux-automatically-时yakuake/konsole启动

Édo*_*pez 6

根据Archlinux wiki 中的Start tmux on every shell Logintmux文章,您可以使用以下代码在 shell 上启动:

Zsh或者Bash

zsh在您的或bash配置(通常~/.zshrc是 或)中添加~/.bashrc以下代码并重新启动会话:

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
Run Code Online (Sandbox Code Playgroud)

Fish

在您的配置中添加fish(通常~/.config/fish/config.fish)以下代码并重新启动会话:

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
Run Code Online (Sandbox Code Playgroud)


Édo*_*pez 5

朋友建议使用<terminal_emulator> -e tmux

孔索

它适用于konsole.

我将菜单中的属性修改为:

konsole -e tmux
Run Code Online (Sandbox Code Playgroud)

药明

但是它不适用于yakuake.