saving and loading tmux copy-paste buffers

37 views
Skip to first unread message

Greg Mattson

unread,
Nov 19, 2021, 12:41:26 PM11/19/21
to tmux-users
all,

I was hoping that there was a way to save all the buffers that I've attained through copy and paste. It really sucks to have a tmux die, only to have hundreds of buffers that I've accumulated die with it.

Is there a way to save these buffers to a file and then reload them when I start a new tmux?

thanks much..

Nicholas Marriott

unread,
Nov 29, 2021, 6:22:40 AM11/29/21
to Greg Mattson, tmux-users
There is no builtin way to do this but it seems like it would be trivial to write a script to save all the buffers every few minutes and reload them when you start the server, something like (to save):

mkdir -p ~/.tmux.d/buffers ~/.tmux.d/buffers.old
rm -f ~/.tmux.d/buffers.old/*
mv ~/.tmux.d/buffers/* ~/.tmux.d/buffers.old
tmux lsb -F '#{buffer_name}'|while read n; do
    tmux saveb -b $n ~/.tmux.d/buffers/$n
done

And to reload:

for n in ~/.tmux.d/buffers/*; do
     case $n in
           buffer*)
                tmux loadb $n
                ;;
           *)
                tmux loadb -b $(basename $n) $n
                ;;
       esac
done

This may need some tweaks to load automatic buffers in the right order (maybe put #{buffer_created} in the name and sort by that?).



--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/4b7eaf16-67ef-4d8e-bb08-3d84a44c4cf4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages