Terminal 如何启动tmux–;自动–;konsole/yakuake何时开始?

Terminal 如何启动tmux–;自动–;konsole/yakuake何时开始?,terminal,tmux,konsole,yakuake,Terminal,Tmux,Konsole,Yakuake,我最近发现了tmux的可能性,我正在yakuake/konsole(类似地震的终端)中使用它。但是,每次启动笔记本电脑或重启雅库克时,我都必须手动启动tmux 如何启动tmux–当yakuake/konsole启动时自动启动?朋友建议使用-e tmux 终端程序 它适用于konsole 我将菜单中的属性修改为: konsole -e tmux 雅库克 但是,当yakuake运行时,它不能与yakuake一起工作: qdbus org.kde.yakuake /yakuake/sessions

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


如何启动
tmux
–当
yakuake
/
konsole
启动时自动启动?

朋友建议使用
-e tmux

终端程序 它适用于
konsole

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

konsole -e tmux
雅库克
但是,当yakuake运行时,它不能与yakuake一起工作:

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 0 "tmux"
根据ArchLinuxWiki上的文章,您可以在

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
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
Fish
在您的
fish
配置(通常为
~/.config/fish/config.fish
)中添加以下代码并重新启动会话:

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
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

我还没有试过使用Yakuake,但我有一种单行shell脚本方法,可以让它与Konsole终端仿真器一起工作

Konsole emulator在启动时设置环境变量

知道这一事实后,我们可以将其添加到
.zshrc
文件中

[-z“$KONSOLE_VERSION”]||tmux
这将启动所有连接到活动tmux会话的KONSOLE窗口,或者如果它是第一个窗口,则创建一个