snarfed.org

draw group stream of consciousness

synchronizing GNU screen's paste buffer and the X selection

Wed, 01 Jan 2003 [comments (5)] [history] [rdf] [raw]

terminal.jpggnu.jpg/space/X_logo.png

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, Ion, Pine, Gaim, and Firefox (God bless Find As You Type), 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. I currently use GNU screen's copy/scrollback mode, with a hack to integrate it with X Windows' clipboard.

This command in my .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 (not Ville Herva's xsel), which needs to be somewhere in your PATH.

See also:

comment bubble OpenID jorges, Wed 03 Jan 2007

THANKS!

comment bubble OpenID Dan, Mon 07 May 2007

That is nice, but I don't think you go far enough... What about mapping C-a to C-x (making commands much more Emacs finger friendly) ... For example, I am now totally stuck on C-a p for 'switching buffers' after C-a c in screen. For this to be 'Emacs' it should be C-x b...

Removing the C-a would be a start...

Thanks for the others though... but where is C-f / C-b ? did you already define that in your rvxt ? (for me it just kills copy mode) .

I guess I am looking for a very Emacs like shell, without running shell in Emacs...

comment bubble OpenID will, Wed 27 Feb 2008

hrmm. im very willing to try this but what i really need is a way to have screen read from the clipboard. i need the file it uses if any. its fairly easy to do in screen irssi/other app via /exec appname command ie. in irssi {/exec firefox www.google.com} you dont really need the writing to clipboard. i need a way to make screen read clipboard. is it possible

comment bubble OpenID raf, Sat 15 Mar 2008

what about that?
bindkey < eval "stuff ' '" "exec sh -c 'xsel -o > /tmp/screen-exchange'" readbuf

comment bubble OpenID czadman, Tue 12 Aug 2008

If you would like full featured keyboard control over firefox user vimperator extension for firefox. I know it is vim-like extension, but is quite powerful.

Cheers

Post a comment...



Simple HTML and wiki markup are allowed.