【问题标题】:How to launch tmux –automatically– when konsole/yakuake start?如何在 konsole/yakuake 启动时自动启动 tmux?
【发布时间】:2014-02-02 14:53:15
【问题描述】:

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

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

【问题讨论】:

    标签: terminal tmux konsole yakuake


    【解决方案1】:

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

    控制台

    它适用于konsole

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

    konsole -e tmux
    

    药化

    但是它不适用于yakuake

    【讨论】:

      【解决方案2】:

      基于来自 Archlinux wiki 的 Start tmux on every shell login 文章,您可以在您的 shell 上使用以下代码启动 tmux

      ZshBash

      在您的zshbash 配置(通常为~/.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
      

      【讨论】:

        【解决方案3】:

        yakuake 运行时:

        qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 0 "tmux"
        

        【讨论】:

          【解决方案4】:

          我没有尝试过使用 Yakuake,但我有一种单行 shell 脚本方法可以使其与 Konsole Terminal Emulator 一起使用。

          Konsole 模拟器在启动时设置KONSOLE_<something> 环境变量。

          知道了这个事实,我们可以把它添加到.zshrc文件中

          [ -z "$KONSOLE_VERSION" ] || tmux
          

          这将启动所有附加到活动 tmux 会话的 KONSOLE 窗口,或者如果它是第一个窗口,则创建一个。

          【讨论】:

            猜你喜欢
            • 2023-03-22
            • 1970-01-01
            • 1970-01-01
            • 2015-01-31
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-11-12
            • 2020-08-18
            相关资源
            最近更新 更多