A wrapper around tmux allowing quick switching and session saving.
Project description
control-tmux
This is a wrapper around tmux that allows you to quickly switch between sessions, save sessions while preserving bash history.
Requirements
- Python 3.6 or higher with PIP. On Ubuntu, run
sudo apt install python3-pip
. - Tmux 3.0a or higher. On Ubuntu, run
sudo apt install tmux
. - Bash 4.0 or higher (probably works with older versions, but not tested)
Installation
control-tmux
can be installed using PIP:
python3 -m pip install control-tmux
In order to use the save and restore features, you must set it up in .bashrc
for each
user. Simply run:
python3 -m controltmux --setup t
This will install tmux.setup.sh
and tmux.default.conf
in your home directory, and add
references to them to .bashrc
and .tmux.conf
.
You can specify one or more aliases to set up for control-tmux
. I recommend t
because
it is short and easy to type, but power users might already have an alias configured. I
use scn
as an alias because this project started out many years ago as a wrapper for GNU
screen
. Aliases will only apply to terminals opened in the future, but you can run exec bash
to reload your aliases in an existing terminal.
The installer will also create a default .tmux.conf if you don't have one. This
configuration is not necessary for control-tmux
to run, but includes many bindings that
make tmux easier to use.
Simple usage
These usage examples all assume you have aliased t
to control-tmux
during installatin
If run without arguments, t
or control-tmux
will list all your current sessions:
To start or switch to a session named blah
, just run t blah
:
This works whether you are running from within tmux or outside of it. If run from outside,
this runs either tmux attach -t blah
or tmux new-session -s blah
(if blah
doesn't
exist) . If run from inside tmux, then it does tmux switch-client -t blah
, which
switches your current client to the session named blah
.
In either case, this will detach any other terminals that are connected to blah
, unless
you prefix the session name with n
(e.g. t n blah
)
To save the blah
session to ~/.tmuxsave/blah.zip
, run t s blah
. To restore, run t r blah
. Restore only works when the session doesn't already exist. You can save all open
sessions by running t s all
:
Restoring a session restores the current working directory and the command history of the shell running within it. It does not automatically restart any commands that were running.
Recovering from a crash
The bash hooks in .tmux.setup.sh
write your history to disk as soon as you launch a
command. In most cases, after a power failure or crash, the session data will be
recoverable. All you need to do is run t s all
before running tmux.
If you forget and try to run t <session>
before t s all
, then it will start a new
instance of tmux and running t s all
will save the sessions from the new index. However,
the data for the old session is still present in ~/.tmuxsave
. Run ls -ld ~/.tmuxsave/tmux-default-*
to see all previous sessions. Each directory will have a
timestamp indicating when that particular instance of tmux was started. Once you have that
directory, just run t -s ~/.tmuxsave/tmux-default-2018-XX-XX__XX-XX-XX s all
and it will
save the sessions from the previous instance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file control-tmux-0.0.11.tar.gz
.
File metadata
- Download URL: control-tmux-0.0.11.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a07c100f9fefcc7ac12d7f1c2d8558b95bbb0193685cbcb877f10a2f5f9a933 |
|
MD5 | 2e9084ff91e8ce95f62a67f7e25d9138 |
|
BLAKE2b-256 | 37c480805c0a1df94bfb05f9e2271cdf5dda2109e6db5d27ccd7999c14738017 |
File details
Details for the file control_tmux-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: control_tmux-0.0.11-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed7348cd492f3d64758c670bd3cec5c45bdef15c9a9297b39b702909f9d50fd |
|
MD5 | 8ba02ff8f26aef7e42f0cda233fcf29b |
|
BLAKE2b-256 | f7c5e982fcb486e9b4c9c1a91e029e2a880661ce71591012d15ab1b183bbe430 |