-
Selecting text in screen and coping to Mac Clipboard
I’ve moved a lot of my day to day development to happen inside of GNU Screen.
I’ve learned about selecting and copying text to the Mac OS X clipboard, so I thought I’d share:
- Enter Scrollback mode: Control-A, then [
- Use arrow keys to navigate up, or across. Control-U scrolls up half a page
- Use the LEFT and RIGHT arrow keys to move. vi commands seem to work here too.
- Press SPACE to start selection mode. Move around, which will select characters.
- Press SPACE when you’re happy and want to copy your selection
Press Control-A, then ] to paste that selection.
Now, there’s a problem: screen doesn’t know about OS X’s clipboard. So “copy your selection” here just means, “Send it to screen’s internal buffers”. And “paste that selection” means, “as long as you’re doing this in screen, that is”.
But we’re on OS X. So copy and paste has a specific meaning: the OS X system clipboard.
Luckily, a line in .screenrc can fix this behavior:
bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"You can find this tip, and some others, for working in the screen scrollback buffer, at Samsarian: GNU Screen: Working with the Scrollback Buffer