我如何设置tmux,使它启动与指定的窗口打开?
当前回答
去https://github.com/remiprev/teamocil看看吧
你可以使用YAML指定你的结构
windows:
- name: sample-window
splits:
- cmd: vim
- cmd:
- ipython
width: 50
- cmd:
height: 25
其他回答
去https://github.com/remiprev/teamocil看看吧
你可以使用YAML指定你的结构
windows:
- name: sample-window
splits:
- cmd: vim
- cmd:
- ipython
width: 50
- cmd:
height: 25
你可以从.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)
这个脚本启动一个名为“e”的会话和三个窗口
#!/bin/sh
tmux new-session -s e -n etc -d 'cd /etc; bash -i'
tmux new-window -t e:1 -n home 'cd ~; bash -i'
tmux new-window -t e:2 -n log 'cd /var/log; bash -i'
tmux select-window -t e:1
tmux -2 attach-session -t e
有一个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启动时自动恢复
我试着用了这一页上的所有想法,但没有一个我喜欢。我只是想要一个解决方案,当我的终端打开时,用一组特定的窗口启动tmux。我还希望它是幂等的,即打开一个新的终端窗口接管tmux会话从前一个。
上面的解决方案通常倾向于打开多个tmux会话,而我只想要一个。首先,我把这个添加到我的~/.bash_profile中:
tmux start-server
if [[ -z "$TMUX" ]]
then
exec tmux attach -d -t default
fi
然后我在我的~/.tmux.conf中添加了以下内容:
new -s default -n emacs /usr/local/bin/emacs
neww -n shell /usr/local/bin/bash
neww -n shell /usr/local/bin/bash
selectw -t 1
现在,每当我启动一个终端或启动tmux或其他什么,我要么重新连接到我现有的所需设置(名为default的会话),要么用该设置创建一个新会话。
推荐文章
- 为什么用反斜杠开始shell命令?
- 遍历带空格的文件列表
- 在Bash中检查传递的参数是否为文件或目录
- 递归复制文件夹,不包括一些文件夹
- 如何在文件中grep不区分大小写的字符串?
- 如何使用文件的行作为命令的参数?
- 如何从命令输出中获得第二列?
- 寻找ALT+LeftArrowKey解决方案在zsh
- 如何做一个非贪婪匹配在grep?
- 在python shell中按方向键时看到转义字符
- Shell命令查找两个文件中的公共行
- 当存储命令输出到变量时,如何保存换行符?
- 如何从shell执行XPath一行程序?
- 如何使用Bash递归创建不存在的子目录?
- 如何将所有子目录中的所有文件压缩成bash中的一个压缩文件