rxvt-unicode

From Gentoo Wiki
Jump to: navigation, search
This page contains changes which are not marked for translation.

Resources

rxvt-unicode, also known simply as urxvt, is a fast and lightweight terminal emulator with xft and unicode support.

Installation

USE flags

USE flags for x11-terms/rxvt-unicode rxvt clone with xft and unicode support

256-color Enable 256 color support local
blink Enable blinking text local
fading-colors Enable colors fading when off focus local
font-styles Enable support for bold and italic fonts local
iso14755 Enable ISO-14755 support local
mousewheel Enable scrolling via mouse wheel or buttons 4 and 5 local
perl Enable perl script support. You can still disable this at runtime with -pe "" local
pixbuf Enable transparency support using gtk's pixbuf local
startup-notification Enable application startup event feedback mechanism global
unicode3 Use 21 instead of 16 bits to represent unicode characters local
xft Build with support for XFT font renderer (x11-libs/libXft) global

Note
Enabling the buffer-on-clear USE flag may result in garbled display of ncurses based programs like top found in sys-process/procps.

Emerge

Install x11-terms/rxvt-unicode:

root #emerge --ask rxvt-unicode

Daemon

It is possible to operate urxvt as a daemon, which will lead to lower resource usage and quicker startup for new terminals. It is a good idea to start the daemon at the beginning of the X session.

The following command will start the daemon and fork it into the background.

user $urxvtd --quiet --opendisplay --fork

After this, new clients can be opened on the single daemon process, rather than spawning new processes for each terminal. To do this, simply run `urxvtc' in place of the usual `urxvt' command. Keep in mind that if for any reason the daemon is terminated, any subsequent `urxvtc' calls as well all client instances will be closed.

Environment variable can be used to specify different location for the daemon ~/.urxvt/urxvtd-hostname listening socket.

CODE The socket location as environment variable
export RXVT_SOCKET='/tmp/urxvt-socket'

Configuration

Configuration for urxvt is done mainly through the X resources system, though command line equivalents are also available in most cases. A full list of these options can be found in the urxvt manpage. Some common configuration options are listed below.

.xinitrc

If you are using .xinitrc, it is possible .Xresources will not be read. To fix this, add the following to .xinitrc

FILE ~/.xinitrc
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

Font

Rxvt-unicode's font can be configured using either XLFD notation or, provided the package was compiled with the xft USE flag, Xft fonts.

FILE ~/.Xresources
! Using XLFD (created via e.g. xfontsel)
URxvt*font:           -misc-fixed-medium-r-semicondensed-*-12-90-100-*-c-60-iso8859-1
! Using Xft
URxvt*font:           xft:Inconsolata:size=8

Fonts can be modified while rxvt-unicode is running by assigning actions to keys:

FILE ~/.Xresources
! Bind C-p to use unifont and show 'halfwidth left corner bracket', U+FF62,「
URxvt.keysym.C-p: 	command:\033]710;xft:Unifont:pixelsize=20\007
! Bind C--, C-0(=) and C-+ to activate small, medium, and big font size resp. 
URxvt.keysym.C-minus: 	command:\033]710;xft:Liberation Mono:pixelsize=12\007
URxvt.keysym.C-0:	command:\033]710;xft:DejaVu Sans Mono:pixelsize=16\007
URxvt.keysym.C-plus:	command:\033]710;xft:Liberation Mono:pixelsize=20\007
Note
In some fonts, depending on the font size Unicode may not work properly.

Rendering settings can be tweaked for Xft fonts as well. Note that this is not specific to urxvt.

FILE ~/.Xresources
Xft.dpi:        96
Xft.antialias:  true
Xft.rgba:       rgb
Xft.hinting:    true
Xft.hintstyle:  hintslight
Xft.autohint:   false
Xft.lcdfilter:  lcddefault

Scrollbar

The look of the scrollbar can be changed, or it can be removed entirely.

FILE ~/.Xresources
URxvt.scrollBar: false
URxvt.scrollBar_right: false
URxvt.scrollBar_floating: false
URxvt.scrollstyle: rxvt

Printing

By default, rxvt-unicode will print out a screen dump, via lpr, when PrntScrn is pressed. Using Ctrl+PrintScrn or Shift-PrintScrn 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.

FILE ~/.Xresources
! The string will be interpreted as if typed into the shell as-is.
! In this example, printing will be disabled altogether.
URxvt.print-pipe: "cat > /dev/null"

Copy/Paste and URL handling

The default urxvt perl extensions can be used for copy and paste actions as well for URL handling capabilities. In order to use Perl extensions in urxvt, the package must have been compiled with the perl USE flag. The x11-misc/urxvt-perls package provides several extensions not included by default. The package sources code can be found in muennich's GitHub repository or an ebuild for example. It is possible to get other Perl extensions.

Here is an example of a ~/.Xresources. The following lines could also be added to ~/.Xdefaults, though ~/.Xresources is preferred.

FILE ~/.Xresources
!-*- Perl extensions -*-
URxvt.perl-ext-common: default,selection-to-clipboard,pasta,matcher,keyboard-select
URxvt.keysym.M-u:     perl:url-select:select_next
URxvt.url-launcher:   /usr/bin/firefox
URxvt.underlineURLs:  True
URxvt.matcher.button: 1 
URxvt.keysym.M-Escape:perl:keyboard-select:activate
URxvt.keysym.Control-Shift-V:     perl:pasta:paste
! Comment this if you don't want copy when text is selected
URxvt.clipboard.autocopy: true

The default selection-to-clipboard extension will put the selected text into the clipboard automatically. To add pasting functionality we have to create a simple extension:

FILE /usr/lib/urxvt/perl/pasta
#! /usr/bin/env perl -w
# Author:   Aaron Caffrey
# Website:  https://github.com/wifiextender/urxvt-pasta
# License:  GPLv3

# Usage: put the following lines in your .Xdefaults/.Xresources:
# URxvt.perl-ext-common           : selection-to-clipboard,pasta
# URxvt.keysym.Control-Shift-V    : perl:pasta:paste

use strict;

sub on_user_command {
  my ($self, $cmd) = @_;
  if ($cmd eq "pasta:paste") {
    $self->selection_request (urxvt::CurrentTime, 3);
  }
  ()
}

Icons

Menu icon

This adds menu entry and menu icon for urxvt. If urxvt doesn't have a .desktop file, create one.

FILE /usr/share/applications/urxvt.desktop
[Desktop Entry]
Name=Urxvt
Comment=Terminal emulator
TryExec=urxvt
Exec=urxvt
Icon=terminal
Type=Application
Categories=GNOME;GTK;Utility;TerminalEmulator;System;
StartupNotify=true

Application icon

For setting application icon x11-terms/rxvt-unicode has to be compiled with pixbuf USE flag.

FILE ~/.Xresources
URxvt.iconFile:    /usr/share/icons/hicolor/scalable/apps/Terminal.svg

Color theme

FILE ~/.Xresources
*background: #0f0f0f
*foreground: #c8c8c8

!black
*color0:  #251f1f
*color8:  #5e5e5e
!red
*color1:  #eb4509
*color9:  #eb4509
!green
*color2:  #94e76b
*color10: #95e76b
!yellow
*color3:  #ffac18
*color11: #ffac18
!blue
*color4:  #46aede
*color12: #46aede
!magenta
*color5:  #e32c57
*color13: #e32c57
!cyan
*color6:  #d6dbac
*color14: #d6dbac
!white
*color7:  #efefef
*color15: #efefef
FILE ~/.XresourcesTango colors
! black
*color0:  #2E3436
*color8:  #555753
! red
*color1:  #a40000
*color9:  #EF2929
! green
*color2:  #4E9A06
*color10: #8AE234
! yellow
*color3:  #C4A000
*color11: #FCE94F
! blue
*color4:  #3465A4
*color12: #729FCF
! purple
*color5:  #75507B
*color13: #AD7FA8
! orange (replaces cyan)
*color6:  #ce5c00
*color14: #fcaf3e
! white
*color7:  #babdb9
*color15: #EEEEEC
FILE ~/.XresourcesLinux colors
! Colors
URxvt*background: #000000
URxvt*foreground: #B2B2B2
! black
URxvt*color0:  #000000
URxvt*color8:  #686868
! red
URxvt*color1:  #B21818
URxvt*color9:  #FF5454
! green
URxvt*color2:  #18B218
URxvt*color10: #54FF54
! yellow
URxvt*color3:  #B26818
URxvt*color11: #FFFF54
! blue
URxvt*color4:  #1818B2
URxvt*color12: #5454FF
! purple
URxvt*color5:  #B218B2
URxvt*color13: #FF54FF
! cyan
URxvt*color6:  #18B2B2
URxvt*color14: #54FFFF
! white
URxvt*color7:  #B2B2B2
URxvt*color15: #FFFFFF

Using rxvt-unicode with Powerline fonts

Unfortunately current default rxvt-unicode configuration in Gentoo breaks support for Powerline characters. Overview of the problem: some fonts provide incorrect values for character width, which breaks their appearance in urxvt in various ways. The Powerline symbols are extra unicode characters, which can be added to a font by "patching" it, or they can be added to the system without patching, using fontconfig settings. These fonts often contain wrong width set for the Powerline characters. Some other terminals workaround that, but not urxvt.

To get Powerline symbols to work correctly, you need the following USE flags to x11-terms/rxvt-unicode:

  • vanilla (which automatically disables the equally problematic alt-font-width)
  • unicode3

For app-misc/powerline (from the raiagent overlay), enable USE flag:

  • fonts, which will pull in media-fonts/powerline-fonts

For media-fonts/powerline-fonts (also from the raiagent overlay), enable one or more USE flags for the fonts you care about, e.g. inconsolata.

Note
The installation of patched fonts from powerline-fonts is the preferred installation method from the Powerline documentation. The alternative method with standard fonts and enabling of powerline-symbols via fontconfig does not seem to work for rxvt-unicode. Nevertheless, media-fonts/powerline-symbols is a mandatory dependency of app-misc/powerline so it is installed anyway.

Finally, in your ~/.Xresources file, set a Powerline font for urxvt (This example assumes the xft USE flag, but the main point is to enable the for Powerline font.

FILE ~/.Xresourcesurxvt font configuration
URxvt*font:           xft:Inconsolata\ for\ Powerline:size=11
Note
After making changes to ~/.Xresources, you need to run a command like
user $xrdb ~/.Xresources
to let the changes have effect.

See also this thread on the urxvt mailing list.

See also