Use Ctrl+b : then pipe-pane -o 'cat >> ~/session.log' to send all pane output to a file. Stop piping with pipe-pane (no arguments).
pipe-pane -o 'cat >> ~/session.log' The pipe-pane command sends all output from a pane to an external command or script. This is incredibly useful for logging sessions, monitoring build processes, or filtering output in real-time.
# Start logging all output pipe-pane -o 'cat >> ~/session.log' # Log with timestamps pipe-pane -o 'ts >> ~/timestamped.log' # Stop piping (no arguments) pipe-pane
You can pipe output through filters to capture only what you need:
# Only log errors pipe-pane 'grep -i error >> ~/errors.log' # Monitor build completion pipe-pane 'grep "Build complete" | notify-send "Build Done"' # Log to syslog pipe-pane 'logger -t tmux-session'
-o: Only output (default, excludes typed commands)-I: Include input (commands you type)-t: Target specific pane# Check if current pane is piped
tmux display -p '#{?pane_pipe,PIPED,NOT_PIPED}'
# List all panes with pipe status
tmux list-panes -F '#{pane_index}: #{?pane_pipe,PIPED,NOT_PIPED}' Use pipe-pane 'tee ~/session.log' to both log output AND display it normally in the pane. The tee command splits the output.
Add this to ~/.tmux.conf to toggle logging:
# Press Ctrl+b P to toggle pane logging
bind-key P if-shell 'tmux display -p "#{?pane_pipe,1,0}" | grep -q 1' \
'pipe-pane' \
'pipe-pane "cat >> ~/logs/#{session_name}-#{window_index}.log"'