Created
December 8, 2023 23:42
-
-
Save beatak/438c2ec3836c3e095012fb864417d5df to your computer and use it in GitHub Desktop.
USAGE: tmux-save-scrollback.sh 2 200
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -r ES_BOLD=$(tput bold) | |
declare -r ES_NORM=$(tput sgr0) | |
declare -r DEFAULT_SCROLLBACK=9999 | |
declare -r MIL_TIME_NOW=$(date +'%Y-%m-%d-%H-%M-%S') | |
declare -r TARGET_PANE=$1 | |
declare -r SCROLLBACK_COUNT=$2 | |
function main { | |
set -eu | |
if [ -z "$TARGET_PANE" ]; then | |
echo "You need to pass a target pane (tmux pane starts from 1)" | |
fi | |
local scroll_back=${SCROLLBACK_COUNT:-$DEFAULT_SCROLLBACK} | |
tmux capture-pane -p -C -t $TARGET_PANE -S -$scroll_back > $MIL_TIME_NOW.txt | |
echo "Pane $TARGET_PANE is saved as $ES_BOLD$MIL_TIME_NOW.txt$ES_NORM" | |
} | |
# ==== | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment