我如何设置tmux,使它启动与指定的窗口打开?
当前回答
你可以从.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)
其他回答
去https://github.com/remiprev/teamocil看看吧
你可以使用YAML指定你的结构
windows:
- name: sample-window
splits:
- cmd: vim
- cmd:
- ipython
width: 50
- cmd:
height: 25
我已经创建了这个脚本。它不需要tmuxinator, ruby或其他。它只是一个bash脚本,可配置:
一个名为config的文件应该包含如下内容:
combo=()
combo+=('logs' 'cd /var/log; clear; pwd')
combo+=('home' 'cd ~; clear; pwd')
bash代码应该是:
#!/bin/bash
if [ -r config ]; then
echo ""
echo "Loading custom file"
. config
else
. config.dist
fi
tmux start-server
window=0
windownumber=-1
for i in "${combo[@]}"; do
if [ $((window%2)) == 0 ]; then
name=${i}
((windownumber++))
else
command=${i}
fi
if [ ${combo[0]} == "${i}" ]; then
tmux new-session -d -s StarTmux -n "${name}"
else
if [ $((window%2)) == 0 ]; then
tmux new-window -tStarTmux:$windownumber -n "${name}"
fi
fi
if [ $((window%2)) == 1 ]; then
tmux send-keys -tStarTmux:$windownumber "${command}" C-m
fi
((window++))
done
tmux select-window -tStarTmux:0
tmux attach-session -d -tStarTmux
你可以从.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)
您可以编写一个小型shell脚本,用所需的程序启动tmux。我在一个称为dev-tmux的shell脚本中有以下内容。开发环境:
#!/bin/sh
tmux new-session -d 'vim'
tmux split-window -v 'ipython'
tmux split-window -h
tmux new-window 'mutt'
tmux -2 attach-session -d
所以每次我想启动我最喜欢的开发环境时,我都可以这样做
$ dev-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
推荐文章
- 为什么用反斜杠开始shell命令?
- 遍历带空格的文件列表
- 在Bash中检查传递的参数是否为文件或目录
- 递归复制文件夹,不包括一些文件夹
- 如何在文件中grep不区分大小写的字符串?
- 如何使用文件的行作为命令的参数?
- 如何从命令输出中获得第二列?
- 寻找ALT+LeftArrowKey解决方案在zsh
- 如何做一个非贪婪匹配在grep?
- 在python shell中按方向键时看到转义字符
- Shell命令查找两个文件中的公共行
- 当存储命令输出到变量时,如何保存换行符?
- 如何从shell执行XPath一行程序?
- 如何使用Bash递归创建不存在的子目录?
- 如何将所有子目录中的所有文件压缩成bash中的一个压缩文件