synchronizing GNU screen's paste buffer and the X selection [![terminal.jpg](/space/terminal.jpg)](http://www.gnu.org/software/screen/)[![gnu.jpg](/space/gnu.jpg)](http://gnu.org/software/emacs/)[![/space/X_logo.png](/space/X_logo.png)](http://x.org/) I hate the mouse. It's good for some things, but not my work. Switching between the mouse and the keyboard wreaks havoc on my muscle memory and fine-motor flow. Thanks to [Emacs](http://gnu.org/software/emacs/), [Ion](http://iki.fi/tuomov/ion), [Pine](http://www.washington.edu/pine/), [Gaim](http://gaim.sf.net), and [Firefox](http://getfirefox.com) (God bless [Find As You Type](http://www.mozilla.org/access/type-ahead/)), I can do everything I need to with the keyboard. The only thing I _can't_ do with the keyboard is copy text from a terminal. And that irks me. In the past, this has driven me to desperate measures, including [running shells inside Emacs](/space/why I don't run shells inside Emacs). I currently use [GNU screen](http://www.gnu.org/software/screen/)'s [copy/scrollback mode](http://www.delorie.com/gnu/docs/screen/screen_73.html), with a hack to integrate it with X Windows' clipboard. This command in [my .screenrc](http://ryan.barrett.name/dotfiles/screenrc) copies screen's paste buffer into the X primary selection. It runs automatically when you press > to set the second mark in copy/scrollback mode. # set the second mark, write to the screen-exchange # file, and use xsel to synchronize the paste buffer # with the X selection. bindkey -m > eval "stuff ' '" writebuf "exec sh -c 'xsel -n < /tmp/screen-exchange'" Note that this uses [Conrad Parker's xsel](http://www.vergenet.net/~conrad/software/xsel/) (_not_ [Ville Herva's xsel](http://www.niksula.cs.hut.fi/~vherva/xsel/)), which needs to be somewhere in your PATH. See also: * [Emacs keybindings in GNU screen's copy-scrollback mode](/space/Emacs keybindings in GNU screen's copy-scrollback mode) * [why I don't run shells inside Emacs](/space/why I don't run shells inside Emacs) * [RatPoison Wiki: mouseless paste](http://ratpoison.elektrubadur.se/mouseless_paste) * [autocutsel clipboard and primary patch](/space/autocutsel clipboard and primary patch) * [control arrow keys in rxvt, tcsh, and emacs](/space/control arrow keys in rxvt, tcsh, and emacs) * [Emacs and remote X Windows](/space/Emacs and remote X Windows)