Add X clipboard support layer to terminal emacs.
The X clipboard allows a user to copy and paste content between different X
windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X
clipboard it well supported in GUI Emacs, but not so well in terminal Emacs
(i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse,
since terminal Emacs has no awareness of X. There are several incomplete Elisp
solutions out that work for the most part, but may not have cross-platform
support, or may fail over SSH with X forwarding or within a `tmux` session.
This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant
binary on each system. For example on Linux, it uses `xsel` or `xclip` to
interface with the clipboard, depending which one is available. It also adds
support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`,
and copy/pasting to and from a remote terminal Emacs. It also supports an edge
case of continuing to work in an Emacs instance running inside a `tmux` session
which may have been started by a different ssh session, which relies on
explicitly reseting the `$DISPLAY` environment variable before calling the
relevant binary.
Yank code inspired by https://github.com/tmux-plugins/tmux-yank.
Fix #4662.
Tried to add xclip support but removed it since it freezes.
2017-05-08 03:08:52 +00:00
#+TITLE : xclipboard layer
2019-05-02 21:49:30 +00:00
#+TAGS : layer|tool
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2018-05-11 04:19:21 +00:00
- [[#description ][Description ]]
2018-05-19 16:43:48 +00:00
- [[#features ][Features: ]]
2019-04-26 14:40:29 +00:00
- [[#requirements ][Requirements ]]
2019-07-07 17:29:31 +00:00
- [[#usage ][Usage ]]
- [[#clipboard-manager-integration ][Clipboard Manager Integration ]]
2020-01-04 02:24:47 +00:00
- [[#custom-copy-paste-command ][Custom Copy Paste Command ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
Add X clipboard support layer to terminal emacs.
The X clipboard allows a user to copy and paste content between different X
windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X
clipboard it well supported in GUI Emacs, but not so well in terminal Emacs
(i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse,
since terminal Emacs has no awareness of X. There are several incomplete Elisp
solutions out that work for the most part, but may not have cross-platform
support, or may fail over SSH with X forwarding or within a `tmux` session.
This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant
binary on each system. For example on Linux, it uses `xsel` or `xclip` to
interface with the clipboard, depending which one is available. It also adds
support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`,
and copy/pasting to and from a remote terminal Emacs. It also supports an edge
case of continuing to work in an Emacs instance running inside a `tmux` session
which may have been started by a different ssh session, which relies on
explicitly reseting the `$DISPLAY` environment variable before calling the
relevant binary.
Yank code inspired by https://github.com/tmux-plugins/tmux-yank.
Fix #4662.
Tried to add xclip support but removed it since it freezes.
2017-05-08 03:08:52 +00:00
* Description
2018-05-19 16:43:48 +00:00
=xclipboard= integration layer.
2019-04-26 14:40:29 +00:00
** Features:
- adds copy support to the X-clipboard from the terminal.
- adds paste support to the X-clipboard from the terminal.
2019-10-13 05:27:17 +00:00
- [[https://github.com/redguardtoo/cliphist ][cliphist ]] package: integration with clipboard managers on Linux and macOS.
2019-04-26 14:40:29 +00:00
* Requirements
2018-11-21 15:30:54 +00:00
This layer depends on a few platform-specific command-line tools:
2019-10-13 05:27:17 +00:00
- on macOS, this layer calls =pbcopy=
2018-11-21 15:30:54 +00:00
- on Windows, this layer calls =clip.exe=
- on GNU/Linux systems, this layer relies on =xsel= to be available.
Note that =xsel= might not be installed by default on e.g. Ubuntu systems.
2019-07-07 17:29:31 +00:00
Clipboard manager integration requires [[http://parcellite.sourceforge.net/ ][Parcellite ]] or [[https://github.com/CristianHenzel/ClipIt ][ClipIt ]] installed on Linux
2019-10-13 05:27:17 +00:00
and [[https://github.com/TermiT/Flycut ][Flycut ]] installed on macOS.
2019-07-07 17:29:31 +00:00
* Usage
** Clipboard Manager Integration
2019-07-11 18:52:32 +00:00
Clipboard manager integration can be enabled by setting =xclipboard-enable-cliphist= to =t= .
#+BEGIN_SRC emacs-lisp
dotspacemacs-configuration-layers '(
(xclipboard :variables xclipboard-enable-cliphist t))
#+END_SRC
2019-07-07 17:29:31 +00:00
2020-01-04 02:24:47 +00:00
** Custom Copy Paste Command
Setting =xclipboard-copy-command= for copy, =xclipboard-paste-command= for paste.
#+BEGIN_SRC emacs-lisp
dotspacemacs-configuration-layers '(
(xclipboard :variables xclipboard-copy-command "utf8clip.exe"))
#+END_SRC
2018-12-05 03:03:03 +00:00
* Key bindings
Add X clipboard support layer to terminal emacs.
The X clipboard allows a user to copy and paste content between different X
windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X
clipboard it well supported in GUI Emacs, but not so well in terminal Emacs
(i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse,
since terminal Emacs has no awareness of X. There are several incomplete Elisp
solutions out that work for the most part, but may not have cross-platform
support, or may fail over SSH with X forwarding or within a `tmux` session.
This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant
binary on each system. For example on Linux, it uses `xsel` or `xclip` to
interface with the clipboard, depending which one is available. It also adds
support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`,
and copy/pasting to and from a remote terminal Emacs. It also supports an edge
case of continuing to work in an Emacs instance running inside a `tmux` session
which may have been started by a different ssh session, which relies on
explicitly reseting the `$DISPLAY` environment variable before calling the
relevant binary.
Yank code inspired by https://github.com/tmux-plugins/tmux-yank.
Fix #4662.
Tried to add xclip support but removed it since it freezes.
2017-05-08 03:08:52 +00:00
2019-07-07 17:29:31 +00:00
| Key binding | Description |
|-------------+--------------------------------------------------------------|
| ~SPC x p~ | Paste clipboard contents at cursor position |
| ~SPC x y~ | Copy selection to clipboard |
| ~SPC x P~ | paste item from history (cliphist must be enabled) |
2019-08-06 13:43:17 +00:00
| ~SPC x R~ | rectangle paste item from history (cliphist must be enabled) |
2019-07-07 17:29:31 +00:00
| ~SPC x s~ | select item from history (cliphist must be enabled) |