Skip to content

Instantly share code, notes, and snippets.

@twe4ked
Created March 26, 2015 17:20
Show Gist options
  • Save twe4ked/f48cfa544536fbde7dd1 to your computer and use it in GitHub Desktop.
Save twe4ked/f48cfa544536fbde7dd1 to your computer and use it in GitHub Desktop.
Grab the last output from tmux
#!/usr/bin/env ruby
#
# The maximum length of a multiplexed packet is 32,768 bytes
#
# Unfortunately this works best (only works) if you have an uncommon character
# in your prompt to split on. I use "»".
FILE = '/tmp/tmux-pane'
PROMPT = '»'
system "tmux capture-pane -S -32768 -p > #{FILE}"
print File.read(FILE).
split(PROMPT)[-2].
lines[1..-2].
join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment