LoginSignup
6
5

More than 5 years have passed since last update.

[Emacs] 選択範囲をクリップボードに送る

Last updated at Posted at 2018-03-23

前置き

tmux上のemacsからウインドウシステムのクリップボードに文字列を送りたい。

Emacsでクリップボードというとx-select-enable-clipboardが常道だが、ターミナル上のEmacsでは動作しないように思われる。

方法

xselをインストール

$ sudo apt install xsel

あとは設定ファイルに以下の関数を定義するだけ。

init.el
(defun x-clipboard-copy ()
  (interactive)
  (when (region-active-p)
    (shell-command-on-region (region-beginning) (region-end) "xsel -ib" nil nil)))

範囲を選択してM-x x-clipboard-copyで選択範囲がクリップボードに送られる。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5