tmuxp shell#
tmuxp shell#
Launch python shell for tmux server, session, window and pane.
Priority given to loaded session/wndow/pane objects:
session_name and window_name arguments
current shell: envvar
TMUX_PANE
for determining window and sessionlibtmux.Server.attached_sessions
,libtmux.Session.attached_window
,libtmux.Window.attached_pane
tmuxp shell [OPTIONS] [SESSION_NAME] [WINDOW_NAME]
Options
- -S <socket_path>#
pass-through for tmux -S
- -L <socket_name>#
pass-through for tmux -L
- -c <command>#
Instead of opening shell, execute python code in libtmux and exit
- --best#
Use best shell available in site packages
- --pdb#
Use plain pdb
- --code#
Use stdlib’s code.interact()
- --ptipython#
Use ptpython + ipython
- --ptpython#
Use ptpython
- --ipython#
Use ipython
- --bpython#
Use bpython
- --use-pythonrc, --no-startup#
Load PYTHONSTARTUP env var and ~/.pythonrc.py script in –code
- --use-vi-mode, --no-vi-mode#
Use vi-mode in ptpython/ptipython
Arguments
- SESSION_NAME#
Optional argument
- WINDOW_NAME#
Optional argument
Directly enter commands#
$ tmuxp shell -c 'python code'
Example#

Guide#
Launch into a python console with libtmux objects. Compare to django’s shell.
Automatically preloads current tmux server
,
session
, window
pane
. Pass additional arguments to select a
specific one of your choice:
(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’s PYTHONBREAKPOINT
and
compatible debuggers, for instance ipdb:
$ pip install --user ipdb
$ env PYTHONBREAKPOINT=ipdb.set_trace tmuxp shell
You can also pass in python code directly, similar to python -c
, do
this via tmuxp -c
:
$ tmuxp shell -c 'print(session.name); print(window.name)'
my_server
my_window
$ tmuxp shell my_server -c 'print(session.name); print(window.name)'
my_server
my_window
$ tmuxp shell my_server my_window -c 'print(session.name); print(window.name)'
my_server
my_window
$ tmuxp shell my_server my_window -c 'print(window.name.upper())'
MY_WINDOW
Assuming inside a tmux pane or one is attached on default server:
$ tmuxp shell -c 'print(pane.id); print(pane.window.name)'
%2
my_window
Shell detection#
tmuxp shell
detects the richest shell available in your site packages, you can also pick your shell via args:
--pdb
: Use plain oldbreakpoint()
(python 3.7+) orpdb.set_trace
--code
: Drop intocode.interact
, accepts--use-pythonrc
--bpython
: Drop into bpython--ipython
: Drop into ipython--ptpython
: Drop into ptpython, accepts--use-vi-mode
--ptipython
: Drop into ipython + ptpython, accepts--use-vi-mode