我如何设置tmux,使它启动与指定的窗口打开?


当前回答

有一个tmux插件。

查看tmux- resurrection

Restore tmux environment after system restart. Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc. There are helpful management tools out there, but they require initial configuration and continuous updates as your workflow evolves or you start new projects. tmux-resurrect saves all the little details from your tmux environment so it can be completely restored after a system restart (or when you feel like it). No configuration is required. You should feel like you never quit tmux.

或tmux-continuum

特点: 持续节约tmux环境 当计算机/服务器打开时自动启动tmux tmux启动时自动恢复

其他回答

tmuxp支持JSON或YAML会话配置和python API。一个用YAML语法创建新会话的简单tmuxp配置文件是:

session_name: 2-pane-vertical
windows:
  - window_name: my test window
    panes:
      - pwd
      - pwd

你可以从.tmux.conf文件中获取不同的会话,如下所示:

# initialize sessions
bind S source-file ~/.tmux/session1 
bind s source-file ~/.tmux/session2

然后按照你的要求设置会议的格式:

#session1
new  -s SessionName -n WindowName Command
neww -n foo/bar foo
splitw -v -p 50 -t 0 bar
selectw -t 1 
selectp -t 0

这将打开2个窗口,其中第二个窗口将命名为foo/bar,并将垂直分为两半(50%),foo运行在bar之上。焦点将在窗口2 (foo/bar),顶部窗格(foo)。

然后,您可以使用PrefixShifts启动首选的tmux会话(在本例中为session1)

这对我很有用。创建5个具有给定名称的窗口,并自动选择到主窗口。

new  -n home
neww -n emacs
neww -n puppet
neww -n haskell
neww -n ruby
selectw -t 1

插件tmux-continuum将自动保存您的tmux会话,并在下次tmux启动时加载它,应该比这里的一些自定义脚本解决方案更容易设置。

特点: 持续节约tmux环境 当计算机/服务器打开时自动启动tmux tmux启动时自动恢复

要按需保存会话,您可以使用tmux- resurrection插件。运行tmux continuum还需要tmux- resurrection

tmux- resurrection保存tmux环境中的所有小细节 因此,它可以在系统重新启动后(或当您重新启动时)完全恢复 感觉像这样)。无需配置。你应该感觉像你自己 永远不要放弃tmux。

试试兄弟,这是一个项目引导器。

它提供了与tmux交互的简单api。

它看起来是这样的:

#!/bin/sh
# @ project_name/tasks/init.sh
structure project_name
  window editor
    run 'vim'
  window terminal
    run 'echo happy coding ...'
focus editor
connect project_name

要启动一个项目,所有人需要做的是运行以下命令-

兄弟开始<project_name>

检查下面的截屏,它展示了如何开始与兄弟和使用它的tmux api。

https://user-images.githubusercontent.com/8296449/50532502-2cf3e400-0b6e-11e9-84af-c5f77a04e5cc.gif