1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
# tmuxp
Session manager for tmux, which allows users to save and load tmux sessions through simple configuration files. Powered by [libtmux](https://github.com/tmux-python/libtmux).
[](https://pypi.org/project/tmuxp/)
[](https://tmuxp.git-pull.com/)
[](https://github.com/tmux-python/tmuxp/actions?query=workflow%3A%22tests%22)
[](https://codecov.io/gh/tmux-python/tmuxp)
[](https://github.com/tmux-python/tmuxp/blob/master/LICENSE)
**New to tmux?** [The Tao of tmux](https://leanpub.com/the-tao-of-tmux)
is available on Leanpub and [Amazon Kindle](http://amzn.to/2gPfRhC).
Read and browse the book for free [on the
web](https://leanpub.com/the-tao-of-tmux/read).
**Have some spare time?** Help us triage and code review and the tracker. See [issue
#290](https://github.com/tmux-python/tmuxp/discussions/290)!
# Installation
pip:
```console
$ pip install --user tmuxp
```
Homebrew:
```console
$ brew install tmuxp
```
Debian / ubuntu:
```console
$ sudo apt install tmuxp
```
Nix:
```console
$ [[ -z $(which tmux) ]] && (nix-env -i tmux && nix-env -i tmuxp) || nix-env -i tmuxp
```
Find the package for your distro on repology: <https://repology.org/project/tmuxp/versions>
Developmental releases:
- [pip](https://pip.pypa.io/en/stable/):
```console
$ pip install --user --upgrade --pre tmuxp
```
- [pipx](https://pypa.github.io/pipx/docs/):
```console
$ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
```
Then use `tmuxp@next load [session]`.
# Load a tmux session
Load tmux sessions via json and YAML,
[tmuxinator](https://github.com/aziz/tmuxinator) and
[teamocil](https://github.com/remiprev/teamocil) style.
```yaml
session_name: 4-pane-split
windows:
- window_name: dev window
layout: tiled
shell_command_before:
- cd ~/ # run as a first command in all panes
panes:
- shell_command: # pane no. 1
- cd /var/log # run multiple commands in this pane
- ls -al | grep \.log
- echo second pane # pane no. 2
- echo third pane # pane no. 3
- echo fourth pane # pane no. 4
```
Save as _mysession.yaml_, and load:
```console
$ tmuxp load ./mysession.yaml
```
Projects with _.tmuxp.yaml_ or _.tmuxp.json_ load via directory:
```console
$ tmuxp load path/to/my/project/
```
Load multiple at once (in bg, offer to attach last):
```console
$ tmuxp load mysession ./another/project/
```
Name a session:
```console
$ tmuxp load -s session_name ./mysession.yaml
```
[simple](http://tmuxp.git-pull.com/examples.html#short-hand-inline) and
[very
elaborate](http://tmuxp.git-pull.com/examples.html#super-advanced-dev-environment)
config examples
# User-level configurations
tmuxp checks for configs in user directories:
- `$TMUXP_CONFIGDIR`, if set
- `$XDG_CONFIG_HOME`, usually _$HOME/.config/tmuxp/_
- `$HOME/.tmuxp/`
Load your tmuxp config from anywhere by using the filename, assuming
_\~/.config/tmuxp/mysession.yaml_ (or _.json_):
```console
$ tmuxp load mysession
```
See [author's tmuxp configs](https://github.com/tony/tmuxp-config) and
the projects'
[tmuxp.yaml](https://github.com/tmux-python/tmuxp/blob/master/.tmuxp.yaml).
# Shell
_New in 1.6.0_:
`tmuxp shell` launches into a python console preloaded with the attached
server, session, and window in
[libtmux](https://github.com/tmux-python/libtmux) objects.
```console
$ tmuxp shell
(Pdb) server
<libtmux.server.Server object at 0x7f7dc8e69d10>
(Pdb) server.sessions
[Session($1 your_project)]
(Pdb) session
Session($1 your_project)
(Pdb) session.name
'your_project'
(Pdb) window
Window(@3 1:your_window, Session($1 your_project))
(Pdb) window.name
'your_window'
(Pdb) window.panes
[Pane(%6 Window(@3 1:your_window, Session($1 your_project)))
(Pdb) pane
Pane(%6 Window(@3 1:your_window, Session($1 your_project))
```
Supports [PEP
553](https://www.python.org/dev/peps/pep-0553/) `breakpoint()`
(including `PYTHONBREAKPOINT`). Also supports direct commands via `-c`:
```console
$ tmuxp shell -c 'print(window.name)'
my_window
$ tmuxp shell -c 'print(window.name.upper())'
MY_WINDOW
```
Read more on [tmuxp shell](https://tmuxp.git-pull.com/cli/shell.html) in
the CLI docs.
# Pre-load hook
Run custom startup scripts (such as installing project dependencies
before loading tmux. See the
[bootstrap_env.py](https://github.com/tmux-python/tmuxp/blob/master/bootstrap_env.py)
and
[before_script](http://tmuxp.git-pull.com/examples.html#bootstrap-project-before-launch)
example
# Load in detached state
You can also load sessions in the background by passing `-d` flag
# Screenshot
<img src="https://raw.githubusercontent.com/tmux-python/tmuxp/master/docs/_static/tmuxp-demo.gif" class="align-center" style="width:45.0%" alt="image" />
# Freeze a tmux session
Snapshot your tmux layout, pane paths, and window/session names.
```console
$ tmuxp freeze session-name
```
See more about [freezing
tmux](https://tmuxp.git-pull.com/cli/freeze.html) sessions.
# Convert a session file
Convert a session file from yaml to json and vice versa.
```console
$ tmuxp convert filename
```
This will prompt you for confirmation and shows you the new file that is
going to be written.
You can auto confirm the prompt. In this case no preview will be shown.
```console
$ tmuxp convert -y filename
$ tmuxp convert --yes filename
```
# Plugin System
tmuxp has a plugin system to allow for custom behavior. See more about
the [Plugin System](http://tmuxp.git-pull.com/plugin_system.html).
# Debugging Helpers
The `load` command provides a way to log output to a log file for
debugging purposes.
```console
$ tmuxp load --log-file <log-file-name> .
```
Collect system info to submit with a Github issue:
```console
$ tmuxp debug-info
------------------
environment:
system: Linux
arch: x86_64
# ... so on
```
# Docs / Reading material
See the [Quickstart](http://tmuxp.git-pull.com/quickstart.html).
[Documentation](http://tmuxp.git-pull.com) homepage (also in
[中文](http://tmuxp-zh.rtfd.org/))
Want to learn more about tmux itself? [Read The Tao of Tmux
online](http://tmuxp.git-pull.com/about_tmux.html).
# Donations
Your donations fund development of new features, testing and support.
Your money will go directly to maintenance and development of the
project. If you are an individual, feel free to give whatever feels
right for the value you get out of the project.
See donation options at <https://git-pull.com/support.html>.
# Project details
- tmux support: 1.8+
- python support: >= 3.9, pypy, pypy3
- Source: <https://github.com/tmux-python/tmuxp>
- Docs: <https://tmuxp.git-pull.com>
- API: <https://tmuxp.git-pull.com/api.html>
- Changelog: <https://tmuxp.git-pull.com/history.html>
- Issues: <https://github.com/tmux-python/tmuxp/issues>
- Test Coverage: <https://codecov.io/gh/tmux-python/tmuxp>
- pypi: <https://pypi.python.org/pypi/tmuxp>
- Open Hub: <https://www.openhub.net/p/tmuxp-python>
- Repology: <https://repology.org/project/tmuxp/versions>
- License: [MIT](http://opensource.org/licenses/MIT).
|