shell, tmux

Smart tmux sessions

Usage

Instead of tmux just type

Installation

Get the code from github, and append it to your .zshrc or .bashrc.

To do it in one step, paste in zsh

, or in bash

New shell sessions will automatically start or resume a tmux session. Comment last line of .zshrc or .bashrc after installation if you do not want this.

Details

The following shell function is my preferred way of starting a shell tmux session.

Tmux consists of a server-client architecture. This is great, because if your terminal is closed, you can later come back and resume exactly where you left off.

One catch of this is that if you are not careful, you can end up with numerous orphan tmux sessions where work is halfway through, vim sessions are still open and so on, and you inadvertedly just open yet another one.

This function simply makes sure that there are no orphan tmux sessions running. If so, it attaches to them.

Upon exiting the shell session, other orphan sessions will be restored, until aren’t any left.

Should you want to leave a session “as is” to come back later, just close the terminal ( or tmux kill-pane ^Ax ). I find this useful for SSH if one includes start_tmux in your .zshrc or .bashrc script.

github

 

Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]

Leave a Reply

Your email address will not be published. Required fields are marked *