tmux-plugins / tmux-logging

Easy logging and screen capturing for Tmux.
MIT License
1.05k stars 114 forks source link

[Feature request] Ability to log every pane and window in a session with one keybind. #45

Open 0xpurecha0s opened 4 years ago

0xpurecha0s commented 4 years ago

Thank you for this outstanding plugin.

Problem Description : Currently when I am about to end my session I manually loop through entire windows and panes in the session and manually type in Alt+Shift+P to create a new directory and save my logs in that directory which then saves this in the naming convention that suits my needs.

Proposition : If at all is it possible to create a key bind say Shift+Alt+S to save the entire logs of a session in one single go i.e to say it will iterate to all windows and panes in them and log them individually to the directory in which the tmux session was started ?

majedchams commented 4 years ago

I also need this feature. That would be a great improvement. Thanks

0xpurecha0s commented 4 years ago

I researched and found something. Unfortunately its not working as I desired it to work. Below is what I did. If somebody can enlighten me with what I am doing wrong.

  1. Created a new file save_complete_history_all_panes.sh in .tmux-logging/scripts
#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CURRENT_DIR/variables.sh"
source "$CURRENT_DIR/shared.sh"

main() {
    if supported_tmux_version_ok; then
        local file=$(expand_tmux_format_path "${save_complete_history_full_filename}")
        local history_limit="$(tmux display-message -p -F "#{history_limit}")"
        for _window in $(tmux list-windows -F '#I'); do
            for _pane in $(tmux list-panes -t ${_window} -F '#P'); do
                tmux capture-pane -J -S "-${history_limit}" -p > "${file}"
                display_message "History saved to ${file}"
            done
        done
    fi
}
main
  1. Create a new key-bind in .tmux-logging/scripts/variables.sh :
    # Complete history capture in all panes.
    default_save_complete_history_all_panes_key="M-S" # Alt+Shift+S
    save_complete_history_all_panes_key=$(tmux show-option -gqv "@save-complete-history-all-panes")
    save_complete_history_all_panes_key=${save_complete_history_all_panes_key:-$default_save_complete_history_all_panes_key}

I thought this should work. Logically speaking it definitely should unfortunately it only captures the pane the key-bind was pressed in. If someone can help/guide me what I am doing wrong. @majedchams @bruno-