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


当前回答

去https://github.com/remiprev/teamocil看看吧

你可以使用YAML指定你的结构

windows:
  - name: sample-window
    splits:
      - cmd: vim
      - cmd:
        - ipython
        width: 50
      - cmd:
        height: 25

其他回答

首先,我有@jasonwryan的方法,但如果你有超过2个配置,它会让人困惑。

所以我创建了一个别名函数:

tmx () {
    tmux "$2" source-file "$HOME/.tmux/$1.conf";
}

在~ /。Tmux / I有多个会话用于许多用途。例如,我在不同的公司工作,他们拥有彼此的开发环境。因此,使用上面的alias函数,我可以简单地调用:tmx company1并加载我需要的配置。

更新:tmux命令后的“$2”的目的是,您可以传递额外的tmux参数。

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

session_name: 2-pane-vertical
windows:
  - window_name: my test window
    panes:
      - pwd
      - pwd
:~$ tmux new-session "tmux source-file ~/session1"  

session1

neww
split-window -v 'ipython'  
split-window -h  
new-window 'mutt'  

在.bashrc中创建别名

:~$ echo `alias tmux_s1='tmux new-session "tmux source-file ~/session1"'` >>~/.bashrc  
:~$ . ~/.bashrc  
:~$ tmux_s1  

有一个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启动时自动恢复

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

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