【发布时间】:2014-02-02 14:53:15
【问题描述】:
我最近发现了tmux 的可能性,我在yakuake/konsole(类似地震的终端)中使用它。但是,每次启动笔记本电脑或重新启动 yakuake 时,我都必须手动启动 tmux。
如何在yakuake/konsole 启动时自动启动tmux ?
【问题讨论】:
标签: terminal tmux konsole yakuake
我最近发现了tmux 的可能性,我在yakuake/konsole(类似地震的终端)中使用它。但是,每次启动笔记本电脑或重新启动 yakuake 时,我都必须手动启动 tmux。
如何在yakuake/konsole 启动时自动启动tmux ?
【问题讨论】:
标签: terminal tmux konsole yakuake
朋友建议使用<terminal_emulator> -e tmux。
它适用于konsole。
我将菜单中的属性修改为:
konsole -e tmux
但是它不适用于yakuake。
【讨论】:
基于来自 Archlinux wiki 的 Start tmux on every shell login 文章,您可以在您的 shell 上使用以下代码启动 tmux
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
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
【讨论】:
yakuake 运行时:
qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 0 "tmux"
【讨论】:
我没有尝试过使用 Yakuake,但我有一种单行 shell 脚本方法可以使其与 Konsole Terminal Emulator 一起使用。
Konsole 模拟器在启动时设置KONSOLE_<something> 环境变量。
知道了这个事实,我们可以把它添加到.zshrc文件中
[ -z "$KONSOLE_VERSION" ] || tmux
这将启动所有附加到活动 tmux 会话的 KONSOLE 窗口,或者如果它是第一个窗口,则创建一个。
【讨论】: