tmux-continuum icon indicating copy to clipboard operation
tmux-continuum copied to clipboard

Find way to run automatically without depending on status bar and status-right

Open studgeek opened this issue 2 years ago • 7 comments

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.

studgeek avatar Sep 10 '21 19:09 studgeek

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).

studgeek avatar Sep 10 '21 19:09 studgeek

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.

studgeek avatar Sep 15 '21 18:09 studgeek

Has anyone found a solution for this or is it just not supported? @studgeek mentioned "add the continuum_save.sh to bash rather than tmux" but I am not sure what that means.

davehouser1 avatar Nov 18 '21 13:11 davehouser1

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.

studgeek avatar Nov 18 '21 16:11 studgeek

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

adrianlzt avatar Dec 13 '21 13:12 adrianlzt

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.

theSafdarAwan avatar Jul 24 '22 20:07 theSafdarAwan

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.

Diablo-D3 avatar Dec 25 '22 03:12 Diablo-D3