LoginSignup
13
13

More than 5 years have passed since last update.

ファイルの内容・標準出力をクリップボードへコピーする

Posted at

xselとxclipがこの目的に使えます.
動作確認したバージョンはxsel 1.2.0, xclip 0.12です.

どちらのコマンドもデフォルトではプライマリセレクション(中クリックで貼り付けできる)が対象である点は共通です.

xclip

ファイル引数と標準入力をともに扱えます.

% xclip test.txt # プライマリへコピー
% echo DELTA | xclip -selection clipboard # クリップボードへコピー

-oオプションで内容を確認できます.

% xclip -o
text.txtの内容
% xclip -o -selection clipboard 
DELTA

xsel

標準入力のみ扱えます. 記事のタイトルの使い方だけなら覚えることが少ないです.

% cat test.txt | xsel # プライマリへ
% cat test.txt | xsel -b # クリップボードへ

-iオプションを指定している文献もあるが必要ない模様.
デフォルトでは内容を表示してくれます.

% xsel
text.txtの内容
% xsel -b
text.txtの内容
13
13
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
13
13