tmux-plugins / tmux-logging

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

how can I trigger screen capture of certain pane from a shell script? #9

Closed dzhao closed 9 years ago

dzhao commented 9 years ago

I need to periodically take a "textual" screen shot of say tmux pane 0. Is there a way I can trigger screen capture from command line? And better yet, is there a way for me to specify which window to capture(not necessarily the current window I am working on?) Thanks so much!

bruno- commented 9 years ago

Hey, I'd recommend just using tmux's native capture-pane for this (that is what this plugin is built around). capture-pane is well documented in man tmux.

I think you'll end up with a command that looks something like this:

tmux capture-pane -J -p -t %123 > file.txt

The %123 is pane unique id. You can get that one by executing echo $TMUX_PANE inside a target pane.

Hope that helps!

I'm going to close this one because it's more related to tmux than to this plugin.

dzhao commented 9 years ago

right on.. thanks so much!

bdowling commented 1 year ago

Still not sure what -J is suppose to do, but -S - works for my use

Here's a random script that might help someone find something in another pane, or the current pane from the command line:

tmux-findpane -- https://gist.github.com/bdowling/c42cb00397eff0d8f8ed625146ead676

alias tmux-history='tmux capture-pane -p -S -'

# especially useful when you want to save some output without re-running expensive commands or grep for something...
tmux-history | sed -e '/^From/,/End/' > save-to-file.