Skip to content

Instantly share code, notes, and snippets.

@backroot
Last active August 8, 2026 11:13
Show Gist options
  • Select an option

  • Save backroot/45eb242ba4d4cac2c03dfc06a07576c0 to your computer and use it in GitHub Desktop.

Select an option

Save backroot/45eb242ba4d4cac2c03dfc06a07576c0 to your computer and use it in GitHub Desktop.
Timestamped tmux logging for macOS
# -----------------------------------------------------------------------------
# Timestamped tmux logging for macOS
#
# Tested with:
# - macOS 26.5.2
# - tmux 3.7b
#
# Requirements:
# mkdir -p ~/tmux-logs
# brew install moreutils
#
# Note:
# - The log may contain ANSI escape sequences and control characters because
# tmux captures the raw pane output.
#
# Logging example:
# [2026-08-08 13:17:02] ^[[1m...user@hostname ~ % echo "Hello" ...
# [2026-08-08 13:17:02] Hello
#
# Usage:
# -----------------------------------------------------------------------------
mkdir -p ~/tmux-logs
brew install moreutils
tmux
tmux pipe-pane -o \
'ts "[%Y-%m-%d %H:%M:%S]" >> ~/tmux-logs/#{session_name}-$(date +%F).log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment