rxvt-unicode

提供: ArchWiki
2018年2月9日 (金) 12:50時点におけるKusakata (トーク | 投稿記録)による版 (同期)
ナビゲーションに移動 検索に移動

関連記事

rxvt-unicode は細かいカスタマイズができるターミナルエミュレータで rxvt のフォークです。一般に urxvt と呼ばれている、rxvt-unicode はデーモン化して一つのプロセスで複数のクライアントを実行することができ、システムリソースの使用を抑えることができます。Marc Lehmann によって開発されており、rxvt-unicode の取り柄としては Unicode による多言語サポートや、透過、複数のフォントタイプの表示機能、Perl 拡張のサポートなどが挙げられます。

インストール

rxvt-unicode パッケージでインストールすることができます。

設定

設定と値の完全なリストは urxvt(1)urxvt(7) を見て下さい。

~/.Xresources の作成

rxvt-unicode の外観や機能はコマンドラインの引数や X resources によって制御されます。コマンドライン引数は X resources の設定よりも優先して適用されます。

urxvt --help は全ての rxvt リソースを標準エラーに出力します。各リソースの説明は man ページに存在します。

スクロールバックの位置

デフォルトでは、シェル出力が更新されると、スクロールバックの表示は自動的にバッファの最後にジャンプし、新しい出力を表示します。前の出力(コンパイラメッセージなど)を表示したい場合は ~/.Xresources に以下のオプションを設定します:

! do not scroll with output
URxvt*scrollTtyOutput: false

! scroll in relation to buffer (with mouse scroll or Shift+Page Up)
URxvt*scrollWithBuffer: true

! scroll back to the bottom on keypress
URxvt*scrollTtyKeypress: true

セカンダリスクリーンのスクロールバッファ

セカンダリスクリーンでページャをスクロールすると (例えば less-X オプションを省略した場合)、端末のバッファではなくページャ内でスクロールできるようスクロールバックバッファを無効にすることをお勧めします。konsole および vte ベースの端末ではデフォルトでこういう仕様になっており動作を変更できません。urxvt で セカンダリスクリーンのスクロールバックバッファを無効にするには:

URxvt.secondaryScreen: 1
URxvt.secondaryScroll: 0

上記の設定は、マウスホイールを使用してスクロールする場合を除いて、期待通りに機能します。マウスホイールでセカンダリスクリーンのページャをスクロールしたとき、スクロールバックバッファに何かがあると、ページャの代わりにスクロールバックバッファがマウスホイールでスクロールされます。この問題を解決するには、rxvt-unicode に新しいオプションを導入する必要があります [1]。AUR の rxvt-unicode-better-wheel-scrollingAUR でパッチが適用された rxvt-unicode が利用できます。パッケージのインストール後、以下を設定ファイルに追加してください:

URxvt.secondaryWheel: 1
ノート: perl 拡張の urxvt-vtwheelAUR は上記のオプションと衝突します。

フォントを宣言する方法

URxvt.font: 9x15

上記の設定は以下と同じです:

URxvt.font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1

同じフォントを太字で使用するには:

URxvt.font: 9x15bold

上記の設定は以下と同じです:

URxvt.font: -misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1

X コアフォントの短縮名の完全なリストは /usr/share/fonts/misc/fonts.alias にあります (/usr/share/fonts/ のサブディレクトリにも fonts.alias ファイルが存在しますが、実際のフォントとは別のパッケージになっているため、インストールされていないフォントも含まれます)。フォントの短縮エイリアスは ISO-10646-1 (Unicode) バージョンではなく ISO-8859-1 バージョンを選択し、100 DPI バージョンではなく 75 DPI バージョンのフォントが使われるため、フォントを選択したいときは長い方の名前を使ってください。

上記はビットマップフォントの話で、他のフォントは以下のように Xft で使うことができます:

URxvt.font: xft:monaco:size=10

または:

URxvt.font: xft:monaco:bold:size=10
ノート: If there is a hyphen(-) in an Xft font name, it must be escaped with backslash(\) twice. It's different from the usage of urxvt -fn option and the result that fc-list returns, where backslash present only once

以下のようにターミナルにエスケープコードを出力することで一時的にフォントをテストすることが可能です:

$ printf '\e]710;%s\007' "xft:Terminus:pixelsize=12"

フォントの間隔

デフォルトでは文字の間隔が広すぎるように感じられる場合、以下のエントリで調整できます:

~/.Xresources
URxvt.letterSpace: -1

-1 で1ピクセル文字の間隔が狭まります。必要ならばもっと狭めることもできます。

カラー

デフォルトで、rxvt-unicode はカラーサポートを有効にしてコンパイルされています。デフォルトの前景色・背景色に加えて、rxvt は256色まで表示することができます (太字・点滅・下線とそれらの組み合わせも可能です)。

foreground, background, cursorColor, cursorColor2, colorBD, colorUL は0から15の数字で色を指定することができ、短い名前で color0-color15 の色を使うことができます。詳しくは #Xresources を参照。

ノート: デフォルトでは urxvtXterm と同じ色を使用しますが、ひとつだけ違う色があります。変更するには Xresources に URxvt.color12: rgb:5c/5c/ff を追加してください。

カットアンドペースト

Rxvt-unicode はデフォルトで PRIMARY セレクションにロードされているカットバッファを使います。詳しくは Selecting and pasting text を見てください。

ALT-CTRL-cALT-CTRL-v でコピーアンドペーストができます。

ノート: 選択したテキストは自動的に PRIMARY にコピーされます。rxvt-unicode 9.20 から perl 拡張selection-to-clipboard を使うことでテキストを CLIPBOARD にコピーできます。

クリップボード#クリップボードマネージャの一覧も参照。

Perl 拡張

クリックできる URL

matcher 拡張を使うことでターミナルに表示された URL をクリックできるようになります。例えば、(規定のウェブブラウザを使って) 左マウスボタンでリンクを開くには、以下を .Xresources に追加します:

URxvt.perl-ext-common: default,matcher
URxvt.url-launcher: /usr/bin/xdg-open
URxvt.matcher.button: 1

rxvt-unicode 9.14 から、キーボードを使って最近閲覧した URL を開いたり確認することもできるようになりました:

URxvt.keysym.C-Delete: perl:matcher:last
URxvt.keysym.M-Delete: perl:matcher:list

Matching links can be colored with a chosen foreground or background color, for example blue:

URxvt.matcher.rend.0: Uline Bold fg5

Alternatively, use colorUL for a #RRGGBB color. This will however color all underlined text, instead of only link matches:

URxvt.colorUL: #4682B4

ヤンクできる URL (マウスを使用しない)

In addition, you can select and open URLs in your web browser without using the mouse.

urxvt-perls パッケージをインストールして適当に .Xresources を調整してください。例:

URxvt.perl-ext: default,url-select
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.url-select.launcher: /usr/bin/xdg-open
URxvt.url-select.underline: true
ノート: This extension replaces the Clickable URLs extension mentioned above, so matcher can be removed from the URxvt.perl-ext list.

キーコマンド:

キー 説明
Alt+u Enter selection mode. The last URL on your screen will be selected. You can repeat Alt+u to select the next upward URL.
k Select next upward URL
j Select next downward URL
Return Open selected URL in browser and quit selection mode
o Open selected URL in browser without quitting selection mode
y Copy (yank) selected URL and quit selection mode
Esc URL 選択モードをキャンセル。

シンプルなタブ

urxvt にタブを追加するには、以下を ~/.Xresources に追加します:

URxvt.perl-ext-common: ...,tabbed,...

タブをコントロールするには:

キー 説明
Shift+Down 新しいタブ
Shift+Left 左のタブに移動
Shift+Right 右のタブに移動
Ctrl+Left タブを左に移動
Ctrl+Right タブを右に移動
Ctrl+d タブを閉じる

タブの色は以下のようにして変更できます:

URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 3
URxvt.tabbed.tab-bg: 0

フルスクリーン

urxvt-fullscreenAUR パッケージをインストールして、urxvt をフルスクリーンにするキーバインディングを設定することができます:

~/.Xresources
...
URxvt.perl-ext-common: ..., fullscreen, ...
URxvt.keysym.F11: perl:fullscreen:switch
...

フォントサイズを即座に変更

urxvt-resize-font-gitAUR パッケージをインストールして ~/.Xresources の Perl 拡張に以下を追加してください:

URxvt.perl-ext-common:  ...,resize-font,...

デフォルトのキーバインド:

  • Ctrl++ (または Ctrl+Shift+=) でサイズを大きくする
  • Ctrl+- でサイズを小さくする
  • Ctrl+= でサイズをリセットする
  • Ctrl+? で現在のサイズを表示

以下のようにキーバインドを変更することもできます:

URxvt.keysym.C-Down:  resize-font:smaller
URxvt.keysym.C-Up:    resize-font:bigger

For the suggested Ctrl+Shift bindings to work, a default binding needs to be disabled (see discussion here):

URxvt.iso14755: false
URxvt.iso14755_52: false

Perl 拡張の無効化

Perl 拡張機能を使っていない場合、完全に Perl 拡張を無効化することでセキュリティと性能を高めることができます:

URxvt.perl-ext:
URxvt.perl-ext-common:
ノート: If you use multiple Perl extension features, you can list them in succession, comma-separated: URxvt.perl-ext-common:default,matcher,tabbed.

インプットメソッドのインライン表示

urxvt でインプットメソッドをインライン表示にする場合は、以下を ~/.Xresources に追加します:

URxvt.perl-ext-common: ...,xim-onthespot,...

インプットメソッドの指定とプレエディットタイプの設定も必要になります (fcitx の部分は自分が使用しているインプットメソッドに変更する必要があります):

URxvt.inputMethod: fcitx
URxvt.preeditType: OnTheSpot

トラブルシューティング

v9.09 にアップグレードした後に透過が機能しない

rxvt-unicode の開発者によって壁紙を設定するプログラムとの互換性が大幅に削除されました。対応していない壁紙設定プログラムを使うと透過が機能しなくなります。推奨されている壁紙設定プログラムは以下です:

  • feh
  • hsetroot
  • esetroot

完全透過を使うには、URxvt.tintColor と URxvt.inheritPixmap をコメントアウトしてください。

リモートホスト

リモートホストにログインしているときに、urxvt-unicode を使ってテキストモードプログラムを実行すると問題が発生することがあります。その場合は rxvt-unicode-terminfo をリモートホストにインストールするかローカルホストの /usr/share/terminfo/r/rxvt-unicode をリモートホストの ~/.terminfo/r/rxvt-unicode にコピーすれば解決できます。rxvt-unicode-256color の場合も同様です。

Some remote systems do not change title automatically unless you specify TERM=xterm. To fix the issue add this line to .bashrc on the remote machine:

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"'

rxvt-unicode を gmrun ターミナルとして使う

Unlike some other terminals, urxvt expects the arguments to -e to be given separately, rather than grouped together with quotes. This causes trouble with gmrun, which assumes the opposite behavior. This can be worked around by putting an "eval" in front of gmrun's "Terminal" variable in .gmrunrc:

Terminal = eval urxvt
TermExec = ${Terminal} -e

(gmrun uses /bin/sh to execute commands, so the "eval" is understood here.) The "eval" has the side-effect of "breaking up" the argument to -e in the same way that $@ does in Bash, making the command intelligible to urxvt.

テンキーの出力がおかしい (例: vim)

Some Debian GNU/Linux users seem to have this problem, although no specific details were reported so far. It is possible that this is caused by the wrong TERM setting, although the details of whether and how this can happen are unknown, as TERM=rxvt should offer a compatible keymap. See the answer to the previous question, and please report if that helped.

However, using the xmodmap program (xorg-xmodmap), you can re-map your number pad keys back.

1. Check the keycode that your numerical keypad (numpad) generates using xev program.

  • Start the xev program
  • Press your number pad keys and look for ... keycode xxx ... in xev's output. For example, numpad 1 in my keyboard is also "End" key, that have a 'keycode 87'.

2. Create or modify your xmodmap file, usually ~/.Xmodmap, with the content representing your keycode.

Example of xmodmap file with number pad keycode:

keycode 63 = KP_Multiply
keycode 79 = Home KP_7
keycode 80 = Up KP_8
keycode 81 = Prior KP_9
keycode 82 = KP_Subtract
keycode 83 = Left KP_4
keycode 84 = KP_5
keycode 85 = Right KP_6
keycode 86 = KP_Add
keycode 87 = End KP_1
keycode 88 = Down KP_2
keycode 89 = Next KP_3
keycode 90 = Insert KP_0
keycode 91 = Delete KP_Decimal
keycode 112 = Prior
keycode 117 = Next

3. Load your xmodmap file at X session start-up.

For example, in ~/.xinitrc file add:

...
xmodmap ~/.Xmodmap
...

特定のキーの組み合わせが機能しない

Get Alt key to work in terminal を見てください。

文字を表示するときに遅くなる

Some programs like alsamixer and xprop do not perform well with some graphics drivers and in consequence redraw very slowly. The option "skipBuiltinGlyphs" for ~/.Xresources or the command line option -sbg may fix this. One possible solution is to add the following to ~/.Xresources:

URxvt*skipBuiltinGlyphs:    true

長い行で動作が遅くなる

The matcher plugin may be the culprit here. It must match a regex against a line every time the line updates, and if you have a large saveLines value this can exacerbate the problem by allowing a very large maximum line length.

There are some simple workarounds:

  • Reduce saveLines
  • Disable the matcher plugin

If neither of those are palatable options, you can compromise by disabling URL matching past a certain cutoff point:

  1. Copy /usr/lib/urxvt/perl/matcher to ~/.urxvt/ext/ (creating the directory if necessary)
  2. Edit ~/.urxvt/ext/matcher, and find the my ($self, $row) = @_; line in the on_line_update sub. It should be line 270.
  3. After that line, insert the line return () if $row < -100;. This disables URL matching on any line that starts more than 100 rows behind the top of the terminal.

参照