Open studgeek opened 3 years ago
I if tmux doesn't have a hook another option would be to add the continuum_save.sh to bash rather than tmux (e.g. PROMPT_COMMAND).
Using bash would allow saving each history from inside each bash session also, which might get rid of https://github.com/tmux-plugins/tmux-resurrect/issues/288.
Has anyone found a solution for this or is it just not supported? @studgeek mentioned "_add the continuumsave.sh to bash rather than tmux" but I am not sure what that means.
I haven't tried it yet, but theory a continuum call could be added to bash's prompt commands to save the history on each prompt. That would require updating bashrc or something though.
Workaround using a systemd timer:
# /home/adrian/.config/systemd/user/tmux-save.service
[Unit]
Description=Save tmux sessions
OnFailure=error@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash /home/adrian/.tmux/plugins/tmux-resurrect/scripts/save.sh
# /home/adrian/.config/systemd/user/tmux-save.timer
[Unit]
Description=Run each ten minutes
[Timer]
OnCalendar=*:0/10
[Install]
WantedBy=timers.target
hey i got this cool hack if you are using any one the window manajers like i3 dwm or bspwm then you can start your terminal like alcritty or kitty and by adding the option /bin/alacritty -e tmux new
then it will pick up the autostart session and will restore it to the last session.
So, I'm doing this, and it seems to be working:
In .tmux.conf
:
run ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
run ~/.tmux/plugins/tmux-continuum/continuum.tmux
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
# (whatever resurrect and continuum options you want)
run ~/.tmux/plugins/tmux-continuum/scripts/continuum_restore.sh
In .bashrc
:
precmd() {
if [ -n "$TMUX" ]; then
eval "$(tmux show-environment -s)"
eval "$($HOME/.tmux/plugins/tmux-continuum/scripts/continuum_save.sh)"
fi
history -a
}
PROMPT_COMMAND=precmd
It seems to correctly save and restore.
It would be nice if continuum didn't depend on tmux status bar being present and needing to modifying status-right.
I'm not sure if there is another hook in tmux to run something regularly though.