Problem Not solved although one answer was accepted: We are working to get Jonah\'s code to work.
Problem: to change the code of (1
There is a much easier solution to just use osascript as found at http://www.samsarin.com/blog/2008/10/18/copying-gnu-screen-buffer-to-leopard-clipboard/
In the comments, Andrew Wason provides this solution to copy the screen buffer:
Code in your .screenrc
# binds C-a b to copy the contents of your last screen copy to the MacOSX pasteboard
bind b eval "writebuf /tmp/screen-pbcopy" "exec /usr/bin/osascript -e 'tell application \"System Events\"' -e 'set the clipboard to (read posix file \"/tmp/screen-pbcopy\" as text)' -e 'end tell'"
Also using osascript, here's a bash script which emulates the behavior of pbcopy within screen. Improvements to this script are welcome:
Save this code as a bash script somewhere in your path, example: ~/bin/pbcopyScreen.bash
#!/bin/bash
# saves all standard input to a file
cat > /tmp/screen_pbcopy_kludge_buffer
# uses osascript to set the MacOSX pastebaord to the contents of the file
/usr/bin/osascript -e 'tell application "System Events"' -e 'set the clipboard to (read posix file "/tmp/screen_pbcopy_kludge_buffer" as text)' -e 'end tell'
rm /tmp/screen_pbcopy_kludge_buffer