tmux is a great tool for “black panel geeks” like me.
For those who don’t know
tmux, it is a
terminal multiplexer for Unix-like operating systems. It enables a number of
terminals to be created, accessed, and controlled from a single screen. tmux may
be detached from a screen and continue running in the background, then later
It is really great for handling terminal sessions whether local or remote.
My pain was with
tmux when I reboot the system my sessions gone. I coded and
tried many scripts that I found like below but none of those worked as I
#!/bin/zsh SESSIONNAME="script" tmux has-session -t $SESSIONNAME &> /dev/null if [ $? != 0 ] then tmux new-session -s $SESSIONNAME -n script -d tmux send-keys -t $SESSIONNAME "~/bin/script" C-m fi tmux attach -t $SESSIONNAME
Finally found a solution for this pain
tmux-resurrect plugin enables saving and restoring tmux sessions manually.
Even if you like to go one step further there is another plugin
tmux-continuum. It saves
sessions automatically. However I am more comfortable with manual savings.
- tmux 1.9 or higher
- Tmux Plugin Manager (recommended)
Add plugin to the list of TPM plugins in
set -g @plugin 'tmux-plugins/tmux-resurrect'
prefix + I to fetch the plugin and source it.
You can save sessions with
prefix + Ctrl + s and restore with
prefix + Ctrl + r. For sure you can always map these binding to another keys.
If you are enjoying my content, maybe you would enjoy buying me a coffee as well.
Just a food for thought.