ArchWiki / Rxvt-unicode
ArchWiki / Rxvt-unicode
de:urxvt ja:Rxvt-unicode ru:Rxvt-unicode zh-hans:Rxvt-unicode
rxvt-unicode (urxvt) is a terminal emulator forked from rxvt, customizable with source-code patches, #X resources and #Perl extensions.
Installation
Install one of the following:
rxvt-unicode-truecolor-wide-glyphs — improved font rendering, enhanced glyph support, applied True color support,
or search Arch User Repository for opinionated builds with different patches and configuration options applied.
Configuration
X resources
Rxvt-unicode is controlled by command-line arguments or X resources. Command-line arguments override, and take precedence over resource settings.
The first component of a resource is either the class—URxvt—or an application (instance) name.
Application name can be specified with urxvt(1) command-line option and is set to urxvt—a binary basename(1)—by default. For a given instance, resources defined with an application name override, and take precedence over defined with the class name ones.
Rxvt-unicode resource naming scheme does not heavily utilize nested components as xterm does. Valid sample of loose binding (asterisk, *) usage is provided in the urxvt(7) section.
See urxvt(1) and urxvt(7) for available settings, X resources and values. Also urxvt --help prints all available resources to the standard error. Each resource can be used as a long command-line option.
Use xrdb(1)—provided by the xorg-xrdb package—to apply the configuration: xrdb ~/.Xresources.
Depending on your environment, you might have to use -merge option.
The new configuration is applied to only new instances, not the existing ones.
Fonts
Rxvt-unicode does not utilize fontconfig library for font substitution when a font or individual character is not present. I.e. you must provide all font names in the corresponding resources—set the fontsets—for all glyphss you are interested in.
* Ability to use non-monospaced fonts—such as Nerd Font vs. Nerd Font Mono—hardly depends on your environment (see #Spacing) and the font itself. * If a glyph cannot be displayed or cannot be found it is substituted with an empty square.
Rxvt-unicode supports both X FreeType (Xft) and X Logical Font Description (XLFD); urclock(1) supports XLFD only.
Permanent
URxvt.font: xft:Input Mono:size13:styleRegular,\
xft:Font Awesome 6 Free:styleSolid
URxvt.boldFont: xft:Input Mono:size13:styleMedium
URxvt.italicFont: xft:Input Mono:size13:styleItalic
URxvt.boldItalicFont: xft:Input Mono:size13:styleMedium Italic~/.XresourcesIf there is a hyphen (-) in an Xft font name, it must be escaped with backslash (\) twice. It is different from the usage of urxvt -fn option and the result that fc-list returns, where backslash present only once.
Non-permanent
You can change the fonts of the current instance with Operating System Command (OSC) sequences. Use numeric (Ps) parameters 710–713 followed by corresponding text (Pt) parameter, such as:
$ printf '\x1b\x5d710;%s\x1b\x5c' "xft:Terminus:pixelsize=22"
$ printf '\e]711;%s\a' "xft:Terminus:pixelsize=22:bold"See also:
Despite the manual page section name, some of OSC sequences presented in that section are not recognized by xterm.
To change font size of the current instance with keyboard shortcuts use resize-font Perl extension.
Spacing
You may need to tweak the horizontal distance between characters with letterSpace and/or the vertical distance between rows with urxvt(1). These needs depend on:
using rendering improvement patches, like enable-wide-glyphs.patch, improve-font-rendering.patch, font-width-fix.patch or line-spacing-fix.patch,
using languages with glyphs that are too different from English letters, like Arabian, Chinese, Hebrew, Japanese or Korean,
your font and its size.
Scrollback buffer
The mouse wheel scrolls five lines by default, and one line while Shift is pressed. If you want to change these numbers — you have to edit the http://cvs.schmorp.de/rxvt-unicode/src/command.C?revision.
Behavior on receiving new output
By default, when shell output appears, the scrollback view will automatically jump to the bottom of the buffer to display new output.
If you want to see previous output (e.g., compiler messages) while pseudo-TTY is still receiving new lines, and jump to the bottom of the scrollback buffer on key press, use the following options:
URxvt.scrollTtyOutput: False
URxvt.scrollWithBuffer: True
URxvt.scrollTtyKeypress: TrueSecondary screen
When you scroll a pager in a secondary screen (e.g. using less(1) without the -X/--no-init option), it may be a good idea to disable secondary screen scroll to be able to scroll in the pager itself, instead of the terminal's buffer.
This is default and unchangeable behavior in Konsole and VTE-based terminal emulators. To achieve the same behavior in urxvt, use the following:
URxvt.secondaryScroll: FalseThe above configuration works as expected, except when scrolling with a mouse wheel. When you scroll a pager in the secondary screen with the mouse wheel, and there has been something in the scrollback buffer — the scrollback buffer will be scrolled by the mouse wheel, instead of the pager itself.
To solve this issue, it is necessary to introduce a new option into urxvt. Use packages like rxvt-unicode-better-wheel-scrolling-unicode3 or rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel , or apply secondaryWheel.patch. After installing, set the following:
URxvt.secondaryWheel: TrueAvoid using this option with the urxvt-vtwheel perl extension, as it will conflict.
Clearance
Reset to Initial State (RIS) ESC 06/03 empties the screen and the scrollback buffer. You can bind it to your desired keys like so:
URxvt.keysym.Meta-Control-l: command:\033cKeeping the screen content on screen clearance
In urxvt pressing Control-L empties the screen, and the screen content is thrown away — you cannot see it in the scrollback buffer later. This behavior might seems controversial for users with Konsole or VTE-based terminal emulators experience, where Control-L keeps the screen content in the scrollback buffer.
To achieve such VTE-like behavior in urxvt you can use appropriate package like rxvt-unicode-better-wheel-scrolling-unicode3 or rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel, or apply clear.patch in your preferred build.
Scrollbar
Scrollbar look and feel is controlled by a dozen of resources. Look at the manual around urxvt(1) and urxvt(1) resources, and see urxvt(1) section.
You can also change visibility of scrollbar on the fly for the current instance with DEC Private Modes urxvt(7) (Pm 30). For example, you can bind scrollbar visibility toggling to a keyboard shortcut:
URxvt.keysym.Meta-Control-s: command:\033[?30tSaving to a file
Ctrl-Print or Shift-Print saves the scrollback buffer content to a file with a setting like so:
URxvt.print-pipe: cat > ~/Downloads/URxvt_$(date '+%Y-%m-%d_%H:%M:%S').txtPrint is usually the Print Screen key.
Print alone saves the screen without the scrollback buffer.
Clipboard
Rxvt-unicode clipboard behavior might seem controversy for people without xterm background. See urxvt(1) for details.
You can use urxvt-eval(1) with key bindings to setup copying to and pasting from CLIPBOARD:
URxvt.keysym.Control-Insert: eval:selection_to_clipboard
URxvt.keysym.Shift-Insert: eval:paste_clipboardurxvt-selection-to-clipboard(1) can be used to synchronize CLIPBOARD with PRIMARY selection.
The urxvt-confirm-paste(1) extension displays a confirmation dialog when a paste containing control characters (like newlines) is detected. It is part of the default set and is loaded automatically, see urxvt(1) and #Disabling Perl extensions for more info.
Perl extensions
We can enable Perl extensions by including the following line:
URxvt.perl-ext-common: extension_name_1,extension_name_2,...There should not be any spacing between extension names.
See also:
urxvt(1) — the resource description
urxvt-extensions(1) — list of available (prepackaged) extensions, do not confuse with
defaultextension set$ man 1 urxvt-extension_name— manual pages for specific prepackaged extensionsurxvtperl(3) — embedded Perl interpreter manual
Clickable URLs
You can make URLs in the terminal clickable using the matcher extension. For example, to open links in the default web browser with the left mouse button, add the following to .Xresources:
URxvt.perl-ext-common: default,matcher
URxvt.url-launcher: /usr/bin/xdg-open
URxvt.matcher.button: 1Since rxvt-unicode 9.14, it is also possible to use matcher to open and list recent (currently limited to 10) URLs via keyboard:
URxvt.keysym.C-Delete: perl:matcher:last
URxvt.keysym.M-Delete: perl:matcher:listMatching links can be colored with a chosen foreground or background color (see urxvt(1)), for example blue:
URxvt.matcher.rend.0: Uline Bold fg4Alternatively, use colorUL for a #RRGGBB color. This will however color all underlined text, instead of only link matches:
URxvt.colorUL: #4682B4Simple tabs
To add tabs to urxvt, add the following to your ~/.Xresources:
URxvt.perl-ext-common: ...,tabbed,...To control tabs use:You can change the colors of tabs with the following:
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 3
URxvt.tabbed.tab-bg: 0In order to make the tabbar transparent set its value to -1
URxvt.tabbed.tabbar-bg: -1If you need to rename the tab, you would probably want to install urxvt-tabbedex instead.
Fullscreen
You can install the AUR package urxvt-fullscreen, and then set a key binding to put urxvt fullscreen.
URxvt.perl-ext-common: ...,fullscreen,...
URxvt.keysym.F11: perl:fullscreen:switchDisabling Perl extensions
If you do not use the Perl extension features, you can improve the security and speed by disabling Perl extensions completely:
URxvt.perl-ext-common:To selectively disable an extension, you need to prepend a hyphen before the extension name:
Urxvt.perl-ext-common: default,-extensionAlternatively, you can explicitly list every extension you need, effectively disabling all others:
URxvt.perl-ext-common: eval,searchable-scrollback,resize-fontTroubleshooting
Wrong shell prompt placement after upgrading to 9.31
Some window managers may have the problem that your prompt appears somewhere in the middle of the window. It may happens on start and/or on window resize. The root cause is update in lines-rewrap algorithm.
To solve the problem you should apply lines-rewrap.patch.
You can also play with geometry, but result is environment– and workflow–dependent, there is no "one size fits all" solution:
Set the real geometry:
URxvt.geometry: 174x47.Set unrealistic geometry:
URxvt.geometry: 400x400.Set rows to -1:
URxvt.geometry: 80x-1.This may lead to inability to use some command line options, for example
urxvt --borderColor black -e mcsometimes opens the terminal for a fraction of second with shell prompt placed in the middle of the first row instead of running Midnight Commander.
Ultimate solution is reverting changes in the source code:
Comment out one line in
screen.C(also seestarttop.patch).Fully revert algorithm changes: 77062#comment216001.
Remote hosts
If you are logging into a remote host, you may encounter problems when running text-mode programs under rxvt-unicode. This can be fixed by installing rxvt-unicode-terminfo on the remote host or by copying /usr/share/terminfo/r/rxvt-unicode from your local machine to your host at ~/.terminfo/r/rxvt-unicode; same for rxvt-unicode-256color.
Some remote systems do not change title automatically unless you specify TERMxterm. To fix the issue add this line to .bashrc on the remote machine:
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"'Another fix you can try is to put following in your .Xresources:
URxvt.termName: rxvtThis is useful when connecting into remote hosts without admin privileges to install terminfo definition for rxvt-unicode.
Using rxvt-unicode as gmrun terminal
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 gmruns Terminal variable in .gmrunrc:
Terminal = eval urxvt
TermExec = ${Terminal} -egmrun 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.
Key combinations do not work
See Get Alt key to work in terminal.
Very long lines cause slowdown
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
saveLinesDisable the
matcherplugin
If neither of those are palatable options, you can compromise by disabling URL matching past a certain cutoff point:
Copy
/usr/lib/urxvt/perl/matcherto~/.urxvt/ext/(creating the directory if necessary)Edit
~/.urxvt/ext/matcher, and find themy ($self, $row) = @_;line in theon_line_updatesub. It should be line 270.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.
No bold text in Midnight Commander
If started under rxvt-unicode with the default TERM setting, text that is usually bold in many other terminals will not appear so. The root of the issue is because xterm couples bright text color with the bold attribute—thus, bright colors will always appear as bold in xterm.
Rxvt-unicode does not have this limitation, which S-Lang—the library Midnight Commander uses for text display by default—honors. Because S-Lang can decouple the bold attribute from bright colors on rxvt-unicode, Midnight Commander would need to explicitly specify the bold attribute as appropriate, https://bugzilla.redhat.com/show_bug.cgi?id.
The solution is to configure Midnight Commander to explicitly use bold colors as desired, e.g. by editing the default skin as follows:
$ mkdir ~/.local/share/mc/skins
$ cp /usr/share/mc/skins/default.ini ~/.local/share/mc/skins/
$ sed -i -E 's/^(.* = (gray|brightred|brightgreen|yellow|brightblue|brightmagenta|brightcyan|white);.*)$/\0;bold/' ~/.local/share/mc/skins/default.iniThe above will create a copy of the default skin, but with all bright colors having an explicit bold attribute added.
See also
Rxvt Unicode — video tutorial by Alex Booker
Browsable CVS — the source code
rxvt-unicode —
enable-wide-glyphs.patchdeveloper's dotfile