Skip to content

antifuchs/tmux_min_attacher

Repository files navigation

TMUX min attacher - reattach to numbered tmux sessions

I launch tmux as my login shell from the terminal by calling just tmux - by default, this creates one session per window. This is usually what I want, except when I accidentally hit Cmd-W and close a terminal window.

Opening a new window then causes a new session to be created, instead of the accidentally-detached session to be re-attached. This was getting pretty annoying to me, so I wrote this program.

Usage

  1. Get Rust 1.10
  2. (optionally) check the PATH that this sets - setting PATH from your shell init files won't cut it here.
  3. (optionally) make test
  4. make install
  5. Set your terminal to run the tmux_min_attacher binary as the command for new windows.
  6. Open and close tabs/windows and be happy

But but but... rust!?

"You could do this from the shell!" - Yep, and I did, for the longest time. Sadly, however, my shell startup is slow enough that this significantly delayed startup of new shells, and what's worse, caused stuff I'd typed ahead of the shell startup to be missed. Hence, Rust. This is fast enough, let me tell you. (No missed typeahead, at least!)

Disclaimer

I've tested this with the 1.10 release of Rust. It uses nix to get access to stable&safe-ish unix interfaces for exec and such, so should be pretty stable - I've been using this code for a few months now. Let me know in the Issues if anything breaks for you. Or, wow, even better, submit a pull request! (:

About

Re-attach to the lowest detached TMUX session number

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published