【发布时间】:2018-02-26 22:09:55
【问题描述】:
我已经尝试了几乎所有可以在网上找到的东西,但没有任何效果。我尝试了以下方法,通常的结果是一个只有一个窗口的新 tmux 会话。
只需在 .bashrc 中。
.bashrc
tmx () {
tmux new-session -A -s SessionName
tmux new-window -n Win1
tmux new-window -n Win2
tmux new-window -n Win3
tmux new-window -n Win4
tmux attach-session -d -t SessionName # with and without this line
tmux select-window -t Win1 # with and without this line
}
同样只在 .bashrc 中。
.bashrc
tmx () {
tmux new-session -A -s SessionName ||
tmux \
neww -s Win1 \; \
neww -s Win2 \; \
neww -s Win3 \; \
neww -s Win4 \; \
selectw -t Win1
}
以下尝试将是我的首选方法,因为它对我来说最有意义。
在没有第一行的情况下调用 tmux 会使所有其他行导致发生“找不到会话”错误。这是没有意义的,因为我们不应该调用 tmux 来访问这些东西吗?我最初的计划是创建一个会话并让这个文件自动设置我的 tmux。
.tmux.conf
new-session -A -s SessionName
new-window -t Win1
new-window -t Win2
new-window -t Win3
new-window -t Win4
attach-session -d -t SessionName # with and without this line
select-window -t Win1 # with and without this line
这种方法,无论是使用别名还是制作函数,通常都会导致“连接服务器失败”。但是,当对它进行足够的调整以使其不会发生时,它会产生与其他结果相同的结果。
.bashrc
alias tmx='tmux source-file "~/.tmux/mysession"'
.tmux/mysession
new-session -A -s SessionName
new-window -t Win1
new-window -t Win2
new-window -t Win3
new-window -t Win4
attach-session -d -t SessionName # with and without this line
select-window -t Win1 # with and without this line
我做错了什么?
【问题讨论】: