Rxvt-unicode: Difference between revisions

From ArchWiki
m (Use the more common {{Lowercase title}})
(→‎Scrollbar: added toggling example)
 
(119 intermediate revisions by 8 users not shown)
Line 2: Line 2:
[[Category:Terminal emulators]]
[[Category:Terminal emulators]]
[[de:urxvt]]
[[de:urxvt]]
[[fr:Rxvt-unicode]]
[[ja:Rxvt-unicode]]
[[ja:Rxvt-unicode]]
[[ru:Rxvt-unicode]]
[[ru:Rxvt-unicode]]
Line 9: Line 8:
{{Related|rxvt-unicode/Tips and tricks}}
{{Related|rxvt-unicode/Tips and tricks}}
{{Related articles end}}
{{Related articles end}}
[http://software.schmorp.de/pkg/rxvt-unicode.html rxvt-unicode] is a customizable terminal emulator forked from [[Wikipedia:Rxvt|rxvt]]. Features of rxvt-unicode include international language support through [[Wikipedia:Unicode|Unicode]], transparency, the ability to display multiple font types and support for [[Perl]] extensions.
[http://software.schmorp.de/pkg/rxvt-unicode.html rxvt-unicode] '''(urxvt)''' is a customizable terminal emulator forked from [[Wikipedia:Rxvt|rxvt]], with support for [[Perl]] extensions.


== Installation ==
== Installation ==


[[Install]] the {{Pkg|rxvt-unicode}} package.
[[Install]] one of the following:
 
* {{Pkg|rxvt-unicode}},
* {{AUR|rxvt-unicode-truecolor-wide-glyphs}} — improved font rendering, enhanced glyph support, applied [[Color_output_in_console#True_color_support|True color]] support,
 
or search [[AUR]] for opinionated [https://aur.archlinux.org/packages?SeB=n&K=rxvt-unicode builds] with different patches and configuration options applied.
 
{| class="wikitable"
|+ Patches
|-
! File name !! Description
|-
| {{ic|7-bit-queries.patch}}
||
:multiple-char sequence for 7-bit queries — is needed for correct work of color ''OSC'' commands
|-
| {{ic|24-bit-color.patch}}
||
:True Color support
|-
| {{ic|256color.patch}}
||
:256 ''~/.Xresources'' colors
|-
| {{ic|background-opacity.patch}}
||
:fixed opacity (''pixbuf-''related)
|-
| {{ic|clear.patch}}
||
:''Control-L'' keeps all lines from the screen in the scrollback buffer (''VTE-''like behavior)
|-
| {{ic|enable-wide-glyphs.patch}}
||
:enhancing glyph support, required by {{ic|improve-font-rendering.patch}}
|-
| {{ic|font-width-fix.patch}}
||
:decreasing space between symbols, incompatible with (replaced by) {{ic|improve-font-rendering.patch}}
|-
| {{ic|improve-font-rendering.patch}}
||
:font rendering improvements
|-
| {{ic|line-spacing-fix.patch}}
||
:vertical spacing improvement, incompatible with (replaced by) {{ic|improve-font-rendering.patch}}
|-
| {{ic|matcher-vi-bindings.patch}}
||
:add ''vi-''style ''(hjkl)'' keys to ''matcher'' extension to mimic deprecated ''ulr-select'' behavior
|-
| {{ic|noinc.diff}}
||
:no increment resizing — is needed for better [[Openbox]] user experience
|-
| {{ic|perl-5.38.patch}}
||
:locale fix required by Perl 5.38
|-
| {{ic|popup-menu-hang.diff}}
||
:fixing ''popup'' Perl extension hanging
|-
| {{ic|rxvt-unicode-sixel.patch}}
||
:DEC [[Wikipedia:Sixel|Sixel]] support
::expressing character bitmap image via DEC ''Device Control String (DCS)'' Sixel {{ic|P…q}} escape sequence
::like "{{ic|ESC}} {{ic|Pq}} {{ic|...}} {{ic|ESC\}}"
|-
| {{ic|rxvt-unicode-truecolor.patch}}
||
:the same as {{ic|24-bit-color.patch}}
|-
| {{ic|secondaryWheel.patch}}
||
:scrolling in the secondary screen with the mouse wheel
|-
| {{ic|starttop.patch}}
||
:commenting out line ''397'' of {{ic|screen.C}} — one of the approaches to the [[#Wrong shell prompt placement after upgrade to 9.31]] problem
|}


== Configuration ==


See {{man|1|urxvt}} and {{man|7|urxvt}} for available settings and values.
{| class="wikitable"
|+ 3rd party Perl Extensions
|-
! File name,
link
! Package
! Description
|-
|[https://github.com/xyb3rt/urxvt-perls/ keyboard-select]
|
||
:use keyboard shortcuts to select and copy text
|-
| [https://github.com/simmel/urxvt-resize-font/ resize-font]
| {{AUR|urxvt-resize-font-git}}
||
:use keyboard shortcuts to adjust the font size; fractional intervals (like {{ic|0.5}}) also supported
|}


=== Xresources ===
== Configuration ==


Rxvt-unicode is controlled by command-line arguments or [[Xresources]]. Command-line arguments override, and take precedence over resource settings, see the [[X resources]] article for details.
''Rxvt-unicode'' is controlled by command-line arguments or [[X resources]]. Command-line arguments override, and take precedence over resource settings.


{{ic|urxvt --help}} prints all available ''rxvt'' resources to standard error. The man page has full explanations of each resource.
See {{man|1|urxvt}} and {{man|7|urxvt}} for available settings, resources and values. Also {{ic|urxvt --help}} prints all available ''URxvt'' resources to the ''standard error.'' Each resource can be used as a long command-line option.


=== Scrollback position ===
Use {{man|1|xrdb}} ({{pkg|xorg-xrdb}}) to apply the configuration like so: {{ic|xrdb ~/.Xresources}}. Depending on your environment you may have to use {{ic|-merge}} option. The new configuration is applied to only new instances, not the existing ones.


By default, when shell output appears the scrollback view will automatically jump to the bottom of the buffer to display new output. If in cases where you want to see previous output (e.g., compiler messages), set the following options in {{ic|~/.Xresources}}:
=== Fonts ===


! do not scroll with output
''Rxvt-unicode'' [[Font_configuration#Applications_without_fontconfig_support|does not utilize]] [https://www.freedesktop.org/wiki/Software/fontconfig/ 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 glyphs you are interested in.
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


=== Scrollback buffer in secondary screen ===
Ability to use non-monospaced fonts (like {{ic|Nerd Font}} vs.  {{ic|Nerd Font '''''Mono'''''}}) hardly depends on your environment (see [[#Spacing]]) and the font itself.


When you scroll a pager in a ''secondary screen'' (e.g. {{ic|less}} without the {{ic|'''-X'''}} option), it may be a good idea to disable the scrollback buffer to be able to scroll in the pager ''itself'', instead of the terminal's buffer: this is default and unchangeable behaviour in konsole and vte-based terminals.
If a glyph can't be displayed or can't be found it is substituted with an empty square.


In urxvt, to disable the scrollback buffer for the ''secondary screen'':
==== Permanent ====


URxvt.secondaryScreen: 1
{{hc|~/.Xresources|
URxvt.secondaryScroll: 0
URxvt.font:          xft:Input Mono:size{{=}}13:style{{=}}Regular, \
                      xft:Vazir Code
URxvt.boldFont:       xft:Input Mono:size{{=}}12:style{{=}}Medium
URxvt.italicFont:    xft:Input Mono:size{{=}}13:style{{=}}Italic
URxvt.boldItalicFont: xft:Input Mono:size{{=}}12:style{{=}}Medium Italic
}}


The 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, instead of the pager itself - the scrollback buffer will be scrolled by the mouse wheel. To solve this issue, it is necessary to introduce a new option into rxvt-unicode [https://bbs.archlinux.org/viewtopic.php?id=132150]. A patched rxvt-unicode is available in AUR as {{aur|rxvt-unicode-better-wheel-scrolling}}. After installing it, add the following to the configuration file:
{{Note|If there is a hyphen ({{ic|-}}) in an Xft font name, it must be escaped with backslash ({{ic|\}}) twice. It is different from the usage of {{ic|urxvt -fn}} option and the result that ''fc-list'' returns, where backslash present only once.}}


URxvt.secondaryWheel: 1
==== Non-permanent ====


{{Note|Avoid using this option with the {{AUR|urxvt-vtwheel}} perl extension, as it will conflict.}}
You can change the fonts of the current instance with [[Xterm]] ''Operating System Commands (OSC)''. Use ''numeric (Ps)'' parameters ''710–713'' followed by corresponding ''text (Pt)'' parameter, like so (also see {{man|1|urxvt|CHANGING FONTS}}):


=== Font declaration methods ===
$ printf '\x1b\x5d710;%s\x1b\x5c' "xft:Terminus:pixelsize=22"
$ printf      '\e]711;%s\a'      "xft:Terminus:pixelsize=22:bold"


URxvt.font: 9x15
To change font size of the current instance with keyboard shortcuts use {{ic|resize-font}} Perl extension.
is the same as:
URxvt.font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1


And, for the same font in bold:
==== Spacing ====


URxvt.font: 9x15bold
You may need to tweak the horizontal distance between characters with {{ic|letterSpace}} and/or the vertical distance between rows with {{man|1|urxvt|lineSpace:}}. 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.


is the same as:
=== Scrollback buffer ===


URxvt.font: -misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1
{{Tip|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{{=}}1.604&view{{=}}markup#l2205 source code].}}


The complete list of short names for X core fonts can be found in {{ic|/usr/share/fonts/misc/fonts.alias}} (there is also some fonts.alias files in some of the other subdirectories of {{ic|/usr/share/fonts/}}, but as they are packaged separately from the actual fonts, they may list fonts you do not actually have installed). It is worth noting that these short aliases select for ISO-8859-1 versions of the fonts rather than ISO-10646-1 (Unicode) versions, and 75 DPI rather than 100 DPI versions, so you are probably better off avoiding them and choosing fonts by their full long names instead.
==== Behavior on receiving new output ====


{{Note|The above paragraph is only for bitmap fonts. Other fonts can be used through Xft using the following format:}}
By default, when shell output appears, the scrollback view will automatically jump to the bottom of the buffer to display new output.
URxvt.font: xft:monaco:size=10


Or
If you want to see previous output (e.g., compiler messages) while [[Linux console#Implementation|''pseudo-TTY'']] is still receiving new lines, and jump to the bottom of the scrollback buffer on key press, use the following options:


  URxvt.font: xft:monaco:bold:size=10
  URxvt.scrollTtyOutput:   False
URxvt.scrollWithBuffer: True
URxvt.scrollTtyKeypress: True


{{Note|If there is a hyphen ({{ic|-}}) in an Xft font name, it must be escaped with backslash ({{ic|\}}) twice. It is different from the usage of {{ic|urxvt -fn}} option and the result that ''fc-list'' returns, where backslash present only once.}}
==== Secondary screen ====


A nice method for testing out fonts in a live terminal before committing to the configuration is by printing escape codes in the terminal, for example:
When you scroll a pager in a ''secondary screen'' (e.g. using {{man|1|less}} without the {{ic|-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.


$ printf '\e]710;%s\007' "xft:Terminus:pixelsize=12"
This is default and unchangeable behavior in [[Konsole]] and [[List_of_applications/Utilities#VTE-based|''VTE-based'']] terminal emulators. To achieve the same behavior in ''urxvt'', use the following:


=== Font spacing ===
URxvt.secondaryScroll: False


By default the distance between characters can feel too wide. The spacing can be reduced by one pixel as such:
The 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.''


{{hc|~/.Xresources|<nowiki>
To solve this issue, it is necessary to introduce [https://bbs.archlinux.org/viewtopic.php?id=132150 a new option] into ''urxvt.'' Use packages like {{AUR|rxvt-unicode-better-wheel-scrolling-unicode3}} or {{AUR|rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel}} , or apply {{ic|secondaryWheel.patch}}. After installing, set the following:
URxvt.letterSpace: -1
</nowiki>}}


There is some debate [http://lists.schmorp.de/pipermail/rxvt-unicode/2007q4/000511.html][http://lists.schmorp.de/pipermail/rxvt-unicode/2007q4/000512.html] over how ''urxvt'' calculates character widths. {{AUR|rxvt-unicode-patched}} changes this calculation, usually resulting in tighter character spacing.
URxvt.secondaryWheel: True


=== Colors ===
{{Note|Avoid using this option with the {{AUR|urxvt-vtwheel}} perl extension, as it will conflict.}}


By default, rxvt-unicode is compiled with color support. In addition to the default foreground and background colors, rxvt can display up to 256 colors (plus high-intensity bold/blinking/underlined and any mix of these).
==== Clearance ====


It is also possible to specify the color values of foreground, background, cursorColor, cursorColor2, colorBD, colorUL as a number 0-15, as a convenient shorthand to reference the color name of color0-color15. See [[#Xresources]] for details.
''Reset to Initial State (RIS)'' {{ic|ESC 06/03}} [https://ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf ''control function''] empties the screen ''and'' the scrollback buffer. You can bind it to your desired keys like so:


{{Note|By default {{ic|urxvt}} uses the same colors as [[Xterm]], except one. Add {{ic|URxvt.color12: rgb:5c/5c/ff}} to Xresources to change this.}}
URxvt.keysym.''Meta-Control-l'': command:\033c


=== Printing ===
==== Keeping the screen content on screen clearance ====
In ''urxvt'' pressing ''Control-L'' empties the screen, and the screen content is thrown away — you can't 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.


By default, rxvt-unicode will print out a screen dump, via lpr, when {{ic|PrintScreen}} is pressed. Using {{ic|Ctrl+PrintScreen}} or {{ic|Shift-PrintScreen}} will include the terminal's scroll back in the printout as well. This behavior can be changed, or disabled entirely, based on personal preference and need.
To achieve such VTE-like behavior in ''urxvt'' you can use appropriate package like
{{AUR|rxvt-unicode-better-wheel-scrolling-unicode3}} or {{AUR|rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel}}, or apply {{ic|clear.patch}} in your preferred build.


{{hc|~/.Xresources|<nowiki>
==== Scrollbar ====
! Disable printing the terminal contents when pressing PrintScreen.
Scrollbar look and feel is controlled by a dozen of resources. Look at the manual around {{man|1|urxvt|scrollstyle:}} and {{man|1|urxvt|scrollColor:}} resources, and see {{man|1|urxvt|THE SCROLLBAR}} section.
URxvt.print-pipe: "cat > /dev/null"
</nowiki>}}


=== Reload the configuration ===
You can also change visibility of scrollbar on the fly for the current instance with ''DEC Private Modes'' {{man|7|urxvt|Escape Sequences}} ({{ic|Pm {{=}} 30}}). For example, you can bind scrollbar visibility toggling to a keyboard shortcut:
After changing the configuration use {{Ic|xrdb ~/.Xresources}} to reload the config. The new configuration is applied for all new terminals.


== Cut and paste ==
URxvt.keysym.Meta-Control-s: command:\033[?30t


Rxvt-unicode uses cut buffers which are loaded into the current {{Ic|PRIMARY}} selection by default. See [http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/doc/rxvt.1.pod#THE_SELECTION_SELECTING_AND_PASTING_ Selecting and pasting text] for details.
==== Saving to a file ====


It is possible to access the {{ic|CLIPBOARD}} selection with the bindings {{ic|ALT-CTRL-c}} and {{ic|ALT-CTRL-v}} for copy and paste respectively.
''Ctrl-Print'' or ''Shift-Print'' saves the ''scrollback buffer'' content to a file with a setting like so:


{{Note|Selected text is automatically copied to {{ic|PRIMARY}} selection. The {{ic|selection-to-clipboard}} [[#Perl extensions|perl extension]], available since {{Pkg|rxvt-unicode}} 9.20, copies to {{ic|CLIPBOARD}} selection as well. }}
URxvt.print-pipe: cat > ~/Downloads/URxvt_$(date '+%Y-%m-%d_%H:%M:%S').txt


If you wish to copy into {{Ic|PRIMARY}} selection and also ensure that your {{ic|CLIPBOARD}} selection is updated with the same contents, you may add the following:
* ''Print'' is usually the ''Print Screen'' key.
* ''Print'' alone saves the screen without the scrollback buffer.


URxvt.perl-ext-common:  ...,selection-to-clipboard,...
=== Clipboard ===


and
''Rxvt-unicode'' [[clipboard]] behavior might seem controversy for people without ''xterm'' background. See {{man|1|urxvt|THE SELECTION: SELECTING AND PASTING TEXT}} for details.


URxvt.clipboard.autocopy: true
You can use {{man|1|urxvt-eval}} with key bindings to setup copying to and pasting from ''CLIPBOARD'':
  URxvt.keysym.M-c: perl:clipboard:copy
  URxvt.keysym.Control-Insert:   eval:selection_to_clipboard
  URxvt.keysym.M-v: perl:clipboard:paste
  URxvt.keysym.Shift-Insert:     eval:paste_clipboard


{{man|1|urxvt-selection-to-clipboard}} can be used to synchronize ''CLIPBOARD'' with ''PRIMARY selection''.


See also [[Clipboard#Managers]].
The {{man|1|urxvt-confirm-paste}} extension displays a confirmation dialog when a paste containing control characters (like newlines) is detected. It is part of the {{ic|default}} set and is loaded automatically, see {{man|1|urxvt|perl-ext-common}} and [[#Disabling Perl extensions]] for more info.


== Perl extensions ==
== Perl extensions ==


{{Style|Bias towards url-select while matcher and url-select are mostly equivalent, as well as man page duplication}}
We can enable Perl extensions by including the following line:


We can enable URxvt perl extensions by including the following line:
URxvt.perl-ext-common: ''extension_name_1'',''extension_name_2'',...


  URxvt.perl-ext-common: extension_name_1,extension_name_2,...
{{Note|There '''should not''' be any spacing between extension names.}}


Please take note that there '''should not''' be any spacing between extension names.
See also:
* {{man|1|urxvt|perl-ext-common}} — the resource description
* {{man|1|urxvt-extensions}} — list of available (prepackaged) extensions, don't confuse with {{ic|default}} extension set
* {{ic|$ man 1 urxvt-''extension_name''}} — manual pages for specific prepackaged extensions
* {{man|3|urxvtperl}} — embedded Perl interpreter manual


=== Clickable URLs ===
=== Clickable URLs ===
Line 164: Line 264:
  URxvt.colorUL: #4682B4
  URxvt.colorUL: #4682B4


=== Yankable URLs (no mouse) ===
In addition, you can select and open URLs in your web browser without using the mouse.
Install the {{Pkg|urxvt-perls}} package from the [[official repositories]] and adjust your {{ic|.Xresources}} as necessary. An example is shown below:
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
{{Note|This extension replaces the Clickable URLs extension mentioned above, so {{Ic|matcher}} can be removed from the {{Ic|URxvt.perl-ext}} list.}}
'''Key commands:'''
{| class="wikitable"
! Key !! Description
|-
| Alt+u || Enter selection mode. The last URL on your screen will be selected. You can repeat {{ic|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 || Cancel URL selection mode
|}


=== Simple tabs ===
=== Simple tabs ===


To add tabs to urxvt, add the following to your {{ic|~/.Xresources}}:
To add tabs to urxvt, add the following to your {{ic|~/.Xresources}}:
  URxvt.perl-ext-common: ...,tabbed,...
  URxvt.perl-ext-common: ...,tabbed,...


Line 204: Line 276:
! Key !! Description
! Key !! Description
|-
|-
| Shift+Down || New tab
| {{ic|Shift+Down}} || New tab
|-
|-
| Shift+Left || Go to left tab
| {{ic|Shift+Left}} || Go to left tab
|-
|-
| Shift+Right || Go to right tab
| {{ic|Shift+Right}} || Go to right tab
|-
|-
| Ctrl+Left || Move tab to the left
| {{ic|Ctrl+Left}} || Move tab to the left
|-
|-
| Ctrl+Right || Move tab to the right
| {{ic|Ctrl+Right}} || Move tab to the right
|-
|-
| Ctrl+d || Close tab
| {{ic|Ctrl+d}} || Close tab
|}
|}


Line 223: Line 295:
  URxvt.tabbed.tab-fg: 3
  URxvt.tabbed.tab-fg: 3
  URxvt.tabbed.tab-bg: 0
  URxvt.tabbed.tab-bg: 0
In order to make the tabbar transparent set its value to -1
URxvt.tabbed.tabbar-bg: -1


If you need to rename the tab, you would probably want to install {{AUR|urxvt-tabbedex}} instead.
If you need to rename the tab, you would probably want to install {{AUR|urxvt-tabbedex}} instead.
Line 230: Line 306:
You can install the [[AUR]] package {{AUR|urxvt-fullscreen}}, and then set a key binding to put urxvt fullscreen.
You can install the [[AUR]] package {{AUR|urxvt-fullscreen}}, and then set a key binding to put urxvt fullscreen.


{{hc|~/.Xresources|
URxvt.perl-ext-common: ...,fullscreen,...
...
URxvt.keysym.F11:       perl:fullscreen:switch
URxvt.perl-ext-common: ...,fullscreen,...
URxvt.keysym.F11: perl:fullscreen:switch
...
}}
 
=== Changing font size on the fly ===
 
Install {{AUR|urxvt-resize-font-git}} from the [[AUR]], add it to your Perl extensions within {{ic|~/.Xresources}}
 
  URxvt.perl-ext-common:  ...,resize-font,...
 
The default keybindings are
* {{ic|Ctrl++}} (or {{ic|1=Ctrl+Shift+=}}) to increase size
* {{ic|Ctrl+-}} to decrease size
* {{ic|1=Ctrl+=}} to reset size
* {{ic|Ctrl+?}} to see current size
 
You can also change key bindings, for example like this:
 
  URxvt.keysym.C-Down:  resize-font:smaller
  URxvt.keysym.C-Up:    resize-font:bigger
 
For the Ctrl+Shift bindings to work, a default binding needs to be disabled (see discussion [https://wilmer.gaa.st/blog/archives/36-rxvt-unicode-and-ISO-14755-mode.html here]):
 
  URxvt.iso14755: false
  URxvt.iso14755_52: false
 
=== Confirm paste ===
 
The {{ic|confirm-paste}} extension is enabled by default and it displays a confirmation dialog when a paste containing control characters is detected.
 
It can be disabled in the following way:
 
URxvt.perl-ext-common:-confirm-paste


=== Disabling Perl extensions ===
=== Disabling Perl extensions ===


If you do not use the Perl extension features, you can improve the security and speed by disabling Perl extensions completely.
If you do not use the Perl extension features, you can improve the security and speed by disabling Perl extensions completely:
URxvt.perl-ext:
  URxvt.perl-ext-common:
  URxvt.perl-ext-common:


To selectively disable an extension, you need to prepend a hyphen before the extension name. For example:
To selectively disable an extension, you need to prepend a hyphen before the extension name:
  Urxvt.perl-ext-common:-extension
  Urxvt.perl-ext-common: default,-''extension''


{{Note|If you use multiple Perl extension features, you can list them in succession, comma-separated: {{ic|URxvt.perl-ext-common:default,matcher,tabbed}}}}
Alternatively, you can explicitly list every extension you need, effectively disabling all others:
URxvt.perl-ext-common: eval,searchable-scrollback,resize-font


== Troubleshooting ==
== Troubleshooting ==


=== Transparency not working after upgrade to v9.09 ===
=== Wrong shell prompt placement after upgrading to 9.31 ===


The rxvt-unicode developers removed compatibility code for a lot of non standard wallpaper setters with this update. Using a non compatible wallpaper setter will break transparency support. Recommended wallpaper setters:
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.


* [[feh]]
You can play with ''geometry'', but result is environment– and workflow–dependent, there is no "one size fits all" solution:
* hsetroot
* Set the real geometry: {{ic|URxvt.geometry: 174x47}}.
* esetroot
* Set unrealistic geometry: {{ic|URxvt.geometry: 400x400}}.
* Set rows to '''''-1''''': {{ic|URxvt.geometry: 80x-1}}.
::This may lead to inability to use some command line options, for example {{ic|urxvt --borderColor black -e mc}} sometimes opens the terminal for a fraction of second with shell prompt placed ''in the middle of the first row'' instead of running [[Midnight Commander]].


To make true transparency work, make sure to comment URxvt.tintColor and URxvt.inheritPixmap.
Ultimate solution is reverting changes in the source code:
* Comment out [https://aur.archlinux.org/packages/rxvt-unicode-truecolor-wide-glyphs?O=10#comment-932862 one line] in {{ic|screen.C}} (also see {{ic|starttop.patch}}).
* Fully revert algorithm changes: {{Bug|77062#comment216001}}.


=== Remote hosts ===
=== Remote hosts ===
Line 314: Line 360:


=== My numerical keypad acts weird and generates differing output? (e.g. in vim) ===
=== My numerical keypad acts weird and generates differing output? (e.g. in vim) ===
 
{{Remove|I would like to remove this section: '''(a)''' It's more than 10 years old, the code has changed a lot. '''(b)''' Maybe it's Debian GNU/Linux-related only (see the first sentence). Do you have this issue with current version in Arch? '''(c)''' '''xmodmap''' is deprecated and often cause troubles, especially if it is used in conjunction with '''setxkbmap''', if the issue is still relevant - it's better to advise to learn '''xkb'''.}}
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.
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.


Line 358: Line 404:


See [https://vim.wikia.com/wiki/Get_Alt_key_to_work_in_terminal?useskin=monobook Get Alt key to work in terminal].
See [https://vim.wikia.com/wiki/Get_Alt_key_to_work_in_terminal?useskin=monobook Get Alt key to work in terminal].
=== Slow performance when drawing glyphs ===
Some programs like alsamixer and xprop do not perform well with some graphics drivers and in consequence redraw very slowly. The option "skipBuiltinGlyphs" for {{ic|~/.Xresources}} or the command line option {{ic|-sbg}} may fix this. One possible solution is to add the following to {{ic|~/.Xresources}}:
URxvt*skipBuiltinGlyphs:    true


=== Very long lines cause slowdown ===
=== Very long lines cause slowdown ===
Line 381: Line 421:


== See also ==
== See also ==
 
* [https://www.youtube.com/playlist?list=PL5ze0DjYv5DYf93rdfDWBRKdwps_-oKnI Rxvt Unicode] — video tutorial by Alex Booker
* [http://software.schmorp.de/pkg/rxvt-unicode.html rxvt-unicode] - Official site
* [http://cvs.schmorp.de/rxvt-unicode/ Browsable CVS] — the source code
* [http://cvs.schmorp.de/rxvt-unicode/ Source Code] - Browseable CVS
* [https://github.com/mrdotx/dotfiles/blob/master/.config/X11/Xresources.d/rxvt-unicode rxvt-unicode] — {{ic|enable-wide-glyphs.patch}} [https://aur.archlinux.org/account/mrdotx developer]'s [[dotfile]]
* [http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/doc/rxvt.7.pod rxvt-unicode FAQ] - Official FAQ
* [http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/doc/rxvt.1.pod rxvt-unicode Reference] - Official manual page
* [http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/src/urxvt.pm urxvtperl] - Official Perl extension reference

Latest revision as of 17:49, 3 May 2024

rxvt-unicode (urxvt) is a customizable terminal emulator forked from rxvt, with support for Perl extensions.

Installation

Install one of the following:

or search AUR for opinionated builds with different patches and configuration options applied.

Patches
File name Description
7-bit-queries.patch
multiple-char sequence for 7-bit queries — is needed for correct work of color OSC commands
24-bit-color.patch
True Color support
256color.patch
256 ~/.Xresources colors
background-opacity.patch
fixed opacity (pixbuf-related)
clear.patch
Control-L keeps all lines from the screen in the scrollback buffer (VTE-like behavior)
enable-wide-glyphs.patch
enhancing glyph support, required by improve-font-rendering.patch
font-width-fix.patch
decreasing space between symbols, incompatible with (replaced by) improve-font-rendering.patch
improve-font-rendering.patch
font rendering improvements
line-spacing-fix.patch
vertical spacing improvement, incompatible with (replaced by) improve-font-rendering.patch
matcher-vi-bindings.patch
add vi-style (hjkl) keys to matcher extension to mimic deprecated ulr-select behavior
noinc.diff
no increment resizing — is needed for better Openbox user experience
perl-5.38.patch
locale fix required by Perl 5.38
popup-menu-hang.diff
fixing popup Perl extension hanging
rxvt-unicode-sixel.patch
DEC Sixel support
expressing character bitmap image via DEC Device Control String (DCS) Sixel P…q escape sequence
like "ESC Pq ... ESC\"
rxvt-unicode-truecolor.patch
the same as 24-bit-color.patch
secondaryWheel.patch
scrolling in the secondary screen with the mouse wheel
starttop.patch
commenting out line 397 of screen.C — one of the approaches to the #Wrong shell prompt placement after upgrade to 9.31 problem


3rd party Perl Extensions
File name,

link

Package Description
keyboard-select
use keyboard shortcuts to select and copy text
resize-font urxvt-resize-font-gitAUR
use keyboard shortcuts to adjust the font size; fractional intervals (like 0.5) also supported

Configuration

Rxvt-unicode is controlled by command-line arguments or X resources. Command-line arguments override, and take precedence over resource settings.

See urxvt(1) and urxvt(7) for available settings, resources and values. Also urxvt --help prints all available URxvt resources to the standard error. Each resource can be used as a long command-line option.

Use xrdb(1) (xorg-xrdb) to apply the configuration like so: xrdb ~/.Xresources. Depending on your environment you may 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 glyphs you are interested in.

Ability to use non-monospaced fonts (like Nerd Font vs. Nerd Font Mono) hardly depends on your environment (see #Spacing) and the font itself.

If a glyph can't be displayed or can't be found it is substituted with an empty square.

Permanent

~/.Xresources
URxvt.font:           xft:Input Mono:size=13:style=Regular, \
                      xft:Vazir Code
URxvt.boldFont:       xft:Input Mono:size=12:style=Medium
URxvt.italicFont:     xft:Input Mono:size=13:style=Italic
URxvt.boldItalicFont: xft:Input Mono:size=12:style=Medium Italic
Note: If 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 Xterm Operating System Commands (OSC). Use numeric (Ps) parameters 710–713 followed by corresponding text (Pt) parameter, like so (also see urxvt(1) § CHANGING FONTS):

$ printf '\x1b\x5d710;%s\x1b\x5c' "xft:Terminus:pixelsize=22"
$ printf      '\e]711;%s\a'       "xft:Terminus:pixelsize=22:bold"

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) § lineSpace:. 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

Tip: 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 source code.

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: True

Secondary 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: False

The 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-unicode3AUR or rxvt-unicode-fontspacing-noinc-vteclear-secondarywheelAUR , or apply secondaryWheel.patch. After installing, set the following:

URxvt.secondaryWheel: True
Note: Avoid using this option with the urxvt-vtwheelAUR perl extension, as it will conflict.

Clearance

Reset to Initial State (RIS) ESC 06/03 control function empties the screen and the scrollback buffer. You can bind it to your desired keys like so:

URxvt.keysym.Meta-Control-l: command:\033c

Keeping the screen content on screen clearance

In urxvt pressing Control-L empties the screen, and the screen content is thrown away — you can't 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-unicode3AUR or rxvt-unicode-fontspacing-noinc-vteclear-secondarywheelAUR, 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) § scrollstyle: and urxvt(1) § scrollColor: resources, and see urxvt(1) § THE SCROLLBAR section.

You can also change visibility of scrollbar on the fly for the current instance with DEC Private Modes urxvt(7) § Escape Sequences (Pm = 30). For example, you can bind scrollbar visibility toggling to a keyboard shortcut:

URxvt.keysym.Meta-Control-s: command:\033[?30t

Saving 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').txt
  • Print 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) § THE SELECTION: SELECTING AND PASTING TEXT 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_clipboard

urxvt-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) § perl-ext-common 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,...
Note: There should not be any spacing between extension names.

See also:

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: 1

Since 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: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


Simple tabs

To add tabs to urxvt, add the following to your ~/.Xresources:

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

To control tabs use:

Key Description
Shift+Down New tab
Shift+Left Go to left tab
Shift+Right Go to right tab
Ctrl+Left Move tab to the left
Ctrl+Right Move tab to the right
Ctrl+d Close tab

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: 0

In order to make the tabbar transparent set its value to -1

URxvt.tabbed.tabbar-bg: -1

If you need to rename the tab, you would probably want to install urxvt-tabbedexAUR instead.

Fullscreen

You can install the AUR package urxvt-fullscreenAUR, and then set a key binding to put urxvt fullscreen.

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

Disabling 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,-extension

Alternatively, you can explicitly list every extension you need, effectively disabling all others:

URxvt.perl-ext-common: eval,searchable-scrollback,resize-font

Troubleshooting

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.

You can 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 mc sometimes 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:

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 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"'

Another fix you can try is to put following in your .Xresources:

URxvt*termName: rxvt

This 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 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.

My numerical keypad acts weird and generates differing output? (e.g. in vim)

This article or section is being considered for removal.

Reason: I would like to remove this section: (a) It's more than 10 years old, the code has changed a lot. (b) Maybe it's Debian GNU/Linux-related only (see the first sentence). Do you have this issue with current version in Arch? (c) xmodmap is deprecated and often cause troubles, especially if it is used in conjunction with setxkbmap, if the issue is still relevant - it's better to advise to learn xkb. (Discuss in Talk:Rxvt-unicode)

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.

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 some keyboards 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
...

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 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.

See also