注解
tmuxp is usable but still needs your help reporting errors, bugs and usability feedback. If you encounter an error, please post on the Issue tracker.
示例(Examples)¶
简洁的语法(Short hand / inline)¶
tmuxp为那些希望配置文件更加精简的用户提供了一套极为简洁语法。
YAML¶
session_name: shorthands
windows:
- window_name: long form
panes:
- shell_command:
- echo 'did you know'
- echo 'you can inline'
- shell_command: echo 'single commands'
- echo 'for panes'
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"echo 'did you know'",
"echo 'you can inline'"
]
},
{
"shell_command": "echo 'single commands'"
},
"echo 'for panes'"
],
"window_name": "long form"
}
],
"session_name": "shorthands"
}
空窗格(Blank panes)¶
无须重复 pwd 和其他任何命令。 可以使用 null, 'blank', 'pane' 中任何一个。 注意 '' 被视为空回车。
YAML¶
session_name: Blank pane test
windows:
# Emptiness will simply open a blank pane, if no shell_command_before.
# All these are equivalent
- window_name: Blank pane test
layout: tiled
panes:
-
- pane
- blank
- null
- shell_command:
- shell_command:
-
# an empty string will be treated as a carriage return
- window_name: Empty string (return)
panes:
- ''
- shell_command: ''
- shell_command:
- ''
JSON¶
{
"windows": [
{
"panes": [
null,
"pane",
"blank",
null,
{
"shell_command": null
},
{
"shell_command": [
null
]
}
],
"layout": "tiled",
"window_name": "Blank pane test"
},
{
"panes": [
"",
{
"shell_command": ""
},
{
"shell_command": [
""
]
}
],
"window_name": "Empty string (return)"
}
],
"session_name": "Blank pane test"
}
设置起始目录(Start Directory)¶
等同于 tmux new-window -c <start-directory>.
YAML¶
session_name: start directory
start_directory: /var/
windows:
- window_name: should be /var/
panes:
- shell_command:
- echo "\033c
- it trickles down from session-level"
- pwd
- window_name: should be /var/log
start_directory: log
panes:
- shell_command:
- echo '\033c
- window start_directory concatenates to session start_directory
- if it is not absolute'
- pwd
- window_name: should be ~
start_directory: '~'
panes:
- shell_command:
- 'echo \\033c ~ has precedence. note: remember to quote ~ in YAML'
- pwd
- window_name: should be /proc
start_directory: /proc
panes:
- echo '\033c absolute paths also have precedence.'
- pwd
- window_name: should be config's dir
start_directory: ./
panes:
- shell_command:
- echo '\033c
- ./ is relative to config file location
- ../ will be parent of config file
- ./test will be \"test\" dir inside dir of config file'
- shell_command:
- echo '\033c
- This way you can load up workspaces from projects and maintain
- relative paths.'
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"echo \"\\033c",
"it trickles down from session-level\""
]
},
"pwd"
],
"window_name": "should be /var/"
},
{
"panes": [
{
"shell_command": [
"echo '\\033c",
"window start_directory concatenates to session start_directory",
"if it is not absolute'"
]
},
"pwd"
],
"start_directory": "log",
"window_name": "should be /var/log"
},
{
"panes": [
{
"shell_command": [
"echo \\\\033c ~ has precedence. note: remember to quote ~ in YAML"
]
},
"pwd"
],
"start_directory": "~",
"window_name": "should be ~"
},
{
"panes": [
"echo '\\033c absolute paths also have precedence.'",
"pwd"
],
"start_directory": "/proc",
"window_name": "should be /proc"
},
{
"panes": [
{
"shell_command": [
"echo '\\033c",
"./ is relative to config file location",
"../ will be parent of config file",
"./test will be \\\"test\\\" dir inside dir of config file'"
]
},
{
"shell_command": [
"echo '\\033c",
"This way you can load up workspaces from projects and maintain",
"relative paths.'"
]
}
],
"start_directory": "./",
"window_name": "should be config's dir"
}
],
"session_name": "start directory",
"start_directory": "/var/"
}
分割出两个窗格(2 split panes)¶
YAML - 简短形式(Short form)¶
session_name: 2-pane-vertical
windows:
- window_name: my test window
panes:
- pwd
- pwd
JSON - 简短形式(Short form)¶
{
"windows": [
{
"panes": [
"pwd",
"pwd"
],
"window_name": "my test window"
}
],
"session_name": "2-pane-vertical"
}
YAML - 圣诞树结构(Christmas Tree)¶
session_name: 2-pane-vertical-long
windows:
- window_name: test
panes:
- shell_command:
- cd ~
- pwd
- top
- shell_command:
- cd /var/www
- pwd
- window_name: second window
shell_command_before: cd /var/www
panes:
- shell_command: pwd
- shell_command:
- pwd
JSON - 圣诞树结构(Christmas Tree)¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"cd ~",
"pwd",
"top"
]
},
{
"shell_command": [
"cd /var/www",
"pwd"
]
}
],
"window_name": "test"
},
{
"panes": [
{
"shell_command": "pwd"
},
{
"shell_command": [
"pwd"
]
}
],
"shell_command_before": "cd /var/www",
"window_name": "second window"
}
],
"session_name": "2-pane-vertical-long"
}
三个面板(3 panes)¶
YAML¶
session_name: 3-panes
windows:
- window_name: dev window
layout: main-vertical
shell_command_before:
- cd ~/
panes:
- shell_command:
- cd /var/log
- ls -al | grep \.log
- pwd
- pwd
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"cd /var/log",
"ls -al | grep \\.log"
]
},
"pwd",
"pwd"
],
"shell_command_before": [
"cd ~/"
],
"layout": "main-vertical",
"window_name": "dev window"
}
],
"session_name": "3-panes"
}
四个面板(4 panes)¶
YAML¶
session_name: 4-pane-split
windows:
- window_name: dev window
layout: tiled
shell_command_before:
- cd ~/
panes:
- shell_command:
- cd /var/log
- ls -al | grep \.log
- pwd
- pwd
- pwd
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"cd /var/log",
"ls -al | grep \\.log"
]
},
"pwd",
"pwd",
"pwd"
],
"shell_command_before": [
"cd ~/"
],
"layout": "tiled",
"window_name": "dev window"
}
],
"session_name": "4-pane-split"
}
自动重命名(Automatic Rename)¶
YAML¶
session_name: test window options
start_directory: '~'
windows:
- layout: main-horizontal
options:
automatic-rename: on
panes:
- shell_command:
- man echo
start_directory: '~'
- shell_command:
- echo "hey"
- shell_command:
- echo "moo"
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"man echo"
],
"start_directory": "~"
},
{
"shell_command": [
"echo \"hey\""
]
},
{
"shell_command": [
"echo \"moo\""
]
}
],
"layout": "main-horizontal",
"options": {
"automatic-rename": true
}
}
],
"session_name": "test window options",
"start_directory": "~"
}
定制主面板高度(Main pane height)¶
YAML¶
session_name: main-pane-height
start_directory: '~'
windows:
- layout: main-horizontal
options:
main-pane-height: 30
panes:
- shell_command:
- top
start_directory: '~'
- shell_command:
- echo "hey"
- shell_command:
- echo "moo"
window_name: my window name
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"top"
],
"start_directory": "~"
},
{
"shell_command": [
"echo \"hey\""
]
},
{
"shell_command": [
"echo \"moo\""
]
}
],
"layout": "main-horizontal",
"options": {
"main-pane-height": 30
},
"window_name": "editor"
}
],
"session_name": "main pane height",
"start_directory": "~"
}
定制高级开发环境(Super-advanced dev environment)¶
YAML¶
session_name: tmuxp
start_directory: ./ # load session relative to config location (project root).
windows:
- window_name: tmuxp
layout: main-horizontal
options:
main-pane-height: 35
shell_command_before:
- command -v virtualenv >/dev/null 2>&1 || { pip install virtualenv; }
- '[ -d .env -a -f .env/bin/activate ] && source .env/bin/activate || virtualenv .env'
- '[ ! -d .env/build ] || rm -rf .env/build'
panes:
- shell_command:
- reset
- vim
- :Ex
focus: true
- shell_command:
- echo hi
- shell_command:
- command -v .env/bin/tmuxp >/dev/null 2>&1 || { pip install -e .; }
- command -v watching_testrunner >/dev/null 2>&1 || { pip install watching_testrunner; }
- watching_testrunner --basepath ./ --pattern="*.py" 'python run_tests.py'
- window_name: docs
layout: main-horizontal
options:
main-pane-height: 35
shell_command_before:
- command -v virtualenv >/dev/null 2>&1 || { pip install virtualenv; }
- '[ -d .env -a -f .env/bin/activate ] && source .env/bin/activate || virtualenv .env'
- '[ ! -d .env/build ] || rm -rf .env/build'
- command -v .env/bin/tmuxp >/dev/null 2>&1 || { pip install -e .; }
- cd ./doc
panes:
- shell_command:
- reset
- vim
- :Ex
focus: true
- pwd
- echo 'docs built to <http://0.0.0.0:8000/_build/html>'; python -m SimpleHTTPServer
- shell_command:
- command -v sphinx-quickstart >/dev/null 2>&1 || { pip install -r requirements.pip; }
- command -v watching_testrunner >/dev/null 2>&1 || { pip install watching_testrunner; }
- watching_testrunner --basepath ./ --pattern="*.rst" 'make html'
- python -m SimpleHTTPServer
JSON¶
{
"windows": [
{
"panes": [
{
"shell_command": [
"reset",
"vim",
":Ex"
],
"focus": true
},
{
"shell_command": [
"echo hi"
]
},
{
"shell_command": [
"command -v .env/bin/tmuxp >/dev/null 2>&1 || { pip install -e .; }",
"command -v watching_testrunner >/dev/null 2>&1 || { pip install watching_testrunner; }",
"watching_testrunner --basepath ./ --pattern=\"*.py\" 'python run_tests.py'"
]
}
],
"shell_command_before": [
"command -v virtualenv >/dev/null 2>&1 || { pip install virtualenv; }",
"[ -d .env -a -f .env/bin/activate ] && source .env/bin/activate || virtualenv .env",
"[ ! -d .env/build ] || rm -rf .env/build"
],
"layout": "main-horizontal",
"window_name": "tmuxp",
"options": {
"main-pane-height": 35
}
},
{
"panes": [
{
"shell_command": [
"reset",
"vim",
":Ex"
],
"focus": true
},
"pwd",
"echo 'docs built to <http://0.0.0.0:8000/_build/html>'; python -m SimpleHTTPServer",
{
"shell_command": [
"command -v sphinx-quickstart >/dev/null 2>&1 || { pip install -r requirements.pip; }",
"command -v watching_testrunner >/dev/null 2>&1 || { pip install watching_testrunner; }",
"watching_testrunner --basepath ./ --pattern=\"*.rst\" 'make html'",
"python -m SimpleHTTPServer"
]
}
],
"shell_command_before": [
"command -v virtualenv >/dev/null 2>&1 || { pip install virtualenv; }",
"[ -d .env -a -f .env/bin/activate ] && source .env/bin/activate || virtualenv .env",
"[ ! -d .env/build ] || rm -rf .env/build",
"command -v .env/bin/tmuxp >/dev/null 2>&1 || { pip install -e .; }",
"cd ./doc"
],
"layout": "main-horizontal",
"window_name": "docs",
"options": {
"main-pane-height": 35
}
}
],
"session_name": "tmuxp",
"start_directory": "./"
}
功夫(Kung fu)¶
注解
tmuxp的会话(session)是可以用python脚本进行定制的。第一个方法是使用 API Reference 中的方法 第二个方法是给 tmuxp.WorkspaceBuilder 传递一个符合规格的 dict 字典。 详见 tmuxp.config.validate_schema() 。
tmuxp需要您的指点,欢迎您在 github 上赐教。