tmux-plugins / tmux-logging

Easy logging and screen capturing for Tmux.
MIT License
1.03k stars 113 forks source link

Automatically turn on logging for new panes #28

Open prokaryont opened 6 years ago

prokaryont commented 6 years ago

Hi, thanks for the nice plugin!

I needed a way of automatically turning on logging for newly created panes. Especially when constructing sessions in detached mode. This was not possible with the original start_logging.sh because it always runs the command on the last selected pane.

The modified start_logging.sh takes a target pane parameter that allows to turn on logging for arbitrary panes.

If one puts a snippet like the following into .bashrc, logging gets automatically enabled for new panes.

if [ -n "$TMUX_PANE" ] && [ "$TMUX_PANE_AUTORUN" != "0" ]; then
  # set TMUX_LOGGING to the path of your tmux-logging installation.
  $TMUX_LOGGING/scripts/start_logging.sh "${log_file}" "${TMUX_PANE}"

  # Prevent autocommand in subshells. We only want the top shell within a
  # tmux pane to run these commands.
  export TMUX_PANE_AUTORUN=0
fi

Would you mind taking a look at the code and checking if it looks reasonable? It works for me on kali with tmux 2.6-rc3.

shmulkinator commented 5 years ago

I wasn't able to get the above to work. Is there any other solution I might try?