tmux 启动时自动分割窗口

tir*_*r38 5 tmux

我有一个类似于这个人的问题/sf/ask/392643471/但更具体。

我想在单个 tmux.conf 文件中执行此操作,无需任何键绑定来根据 @jasonwryan 的答案加载特定会话。

那么,我该怎么做呢?我设置了 tmux.conf:

new  -s mySession -n myWindow
neww -n foo/bar foo
splitw -v -p 50 -t 0 bar
selectw -t 1 
selectp -t 0
Run Code Online (Sandbox Code Playgroud)

但当我启动 tmux 时它不会分割窗口。


更新:我认为附件不起作用。如果我放弃第二个“foo”窗口并简化我的 tmux.conf :

# set panes the way I want them
# if I started tmux by just running 'tmux' in command line, it automatically creates session(0) so...

new -s mySession -n myWindow    # ... create new session (1) with new window (0)
select-window -t myWindow       # select myWindow (0)
splitw -v -p 50 -t myWindow     # split myWindow (0) vertically into halves(50 percent)


attach -s mySession             # error usage: attach-session [-dr] [-t target-session]
attach-session -t mySession     # so this doesn't work either
switch -t mySession             # nor doesn't work
Run Code Online (Sandbox Code Playgroud)

那么我错过了什么?如果我在 tmux 启动后通过执行 CTRL+bs 然后选择 mySession 来手动切换会话,那么窗格将被拆分,一切都很好。那么如何从 session(0) 附加到 mySession 或切换到 mySession?

che*_*ner 0

创建新会话、创建新窗口并将窗口拆分为 2 个窗格后,您仍然需要附加到会话。添加

attach -s mySession
Run Code Online (Sandbox Code Playgroud)

到上面显示的命令的末尾。