Rxvt-unicode
From ArchWiki
rxvt-unicode is a highly customizable terminal emulator forked from rxvt. Commonly known as urxvt, rxvt-unicode can be daemonized to run clients within a single process in order to minimize the use of system resources. Developed by Marc Lehmann, some of the more outstanding features of rxvt-unicode include international language support through Unicode, the ability to display multiple font types and support for Perl extensions.
Contents |
Installation
Install the latest version of rxvt-unicode:
# pacman -Sy rxvt-unicode
or
# pacman -Sy rxvt-unicode-256color
to install rxvt with 256 color support
Configuration
Creating ~/.Xdefaults
The look, feel and function of rxvt-unicode is typically controlled by way of either command-line arguments, or resource settings within the file ~/.Xdefaults. Create if not present:
$ cd ~ $ touch .Xdefaults
All that is left at this point is to enter desired settings by editing the file.
Example ~/.Xdefaults
rxvt-unicode Example Screenshot
URxvt.buffered: true URxvt.background: black URxvt.foreground: white URxvt.cursorColor: green URxvt.underlineColor: yellow URxvt.font: xft:Terminus:pixelsize=14:antialias=false URxvt.boldFont: xft:Terminus:bold:pixelsize=14:antialias=false URxvt.perl-ext-common: default,tabbed URxvt.title: ArchWiki Example
See the rxvt-unicode reference page for the complete list of available setting and values.
Tips and tricks
Clickable URLs
You can make URLs in the terminal clickable if you have Perl installed. For example, to open links in Firefox add the following to .Xdefaults:
URxvt.perl-ext: default,matcher URxvt.urlLauncher: /usr/bin/firefox URxvt.matcher.button: 1
Cut and paste
For users unfamiliar with Xorg's data transfer methods, the exchange of information to and from rxvt-unicode can become a burden. Suffice to say that rxvt-unicode uses cut buffers which are typically loaded into the current PRIMARY selection by default.[1] Users are urged to review Wikipedia:X Window selection for additional information.
Clipboard management
- Parcellite is an actively developed GTK+ clipboard manager which can also run in the background as a daemon.
- autocutsel provides command line and daemon interfaces to synchronize PRIMARY, CLIPBOARD and cut buffer selections.
- Glipper is a GNOME panel applet with older versions available for use in environments other than GNOME.
No clipboard management solution
Skottish[2] created a perl script to automatically copy any selection in urxvt to the X clipboard. Save the following as /usr/lib/urxvt/perl/clipboard:
#! /usr/bin/perl sub on_sel_grab { my $query=quotemeta $_[0]->selection; $query=~ s/\n/\\n/g; $query=~ s/\r/\\r/g; system( "echo -en " . $query . " | xsel -ibp" ); }
It also requires xsel and needs to be enabled in the *perl-ext-common field in .Xdefaults. There should be a line in .Xdefaults that looks like this:
urxvt*perl-ext-common: default,matcher,clipboard
Font declaration methods
URxvt.font: 9x15
is the same as
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1
and
URxvt.font: 9x15bold
is the same as
URxvt.font: -misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1
Fix maximized window gaps
When the amount of lines do not fit the resolution, urxvt will make gaps along the lower and right window border in order to properly fit the contents. By slightly altering the line calculation formula, urxvt will employ other means to "count" the lines.
Apply the following patch:
Index: src/main.C =================================================================== RCS file: /schmorpforge/rxvt-unicode/src/main.C,v retrieving revision 1.303 diff -u -r1.303 main.C --- src/main.C 27 Jan 2008 22:48:33 -0000 1.303 +++ src/main.C 1 Feb 2008 16:27:59 -0000 @@ -644,6 +644,8 @@ ncol = width / fwidth; nrow = height / fheight; + width = ncol * fwidth; + height = nrow * fheight; } /*----------------------------------------------------------------------*/
Improved Kuake-like behavior in Openbox
This was originally posted on the forum by Xyne[3] and it relies on xdotool which is available in the community repo.
The scriptlets
Save this scriptlet from the urxvtc man page somewhere on your system as urxvtc (e.g., in ~/.config/openbox):
#!/bin/sh urxvtc "$@" if [ $? -eq 2 ]; then urxvtd -q -o -f urxvtc "$@" fi
and save this one as urxvtq:
#!/bin/bash wid=$(xdotool search --name urxvtq) if [ -z "$wid" ]; then /path/to/urxvtc -name urxvtq -geometry 80x28 wid=$(xdotool search --name urxvtq) xdotool windowfocus $wid xdotool key Control_L+l else if [ -z "$(xdotool search --onlyvisible --name urxvtq 2>/dev/null)" ]; then xdotool windowmap $wid xdotool windowfocus $wid else xdotool windowunmap $wid fi fi
Make sure that you change /path/to/urxvtc to the actual path to the urxvtc scriptlet that you saved above. We'll be using urxvtc to launch both regular instances of urxvt and the kuake-like instance.
urxvtq with tabbing
If you want to have tabs in your kuake-like urxvtc (here called urxvtq) just replace the third line in your urxvtq:
wid=$(xdotool search --name urxvtq)
with:
wid=$(xdotool search --name urxvtq | grep -m 1 )
To activate the tab support, you can either replace the fifth line of your urxvtq:
/path/to/urxvtc -name urxvtq -geometry 80x28
with:
/path/to/urxvtc -name urxvtq -pe tabbed -geometry 80x28
or replace this line of your .Xdefaults:
URxvt.perl-ext-common: default,matcher
with
URxvt.perl-ext-common: default,matcher,tabbed
Tab control
<SHIFT>-Left: Switch to the tab left of current one
<SHIFT>-Right: Switch to the tab right of current one
<SHIFT>-Down: Create a new tab
You can also use your mouse to switch the tabs by clicking the wished one and create a new tab by clicking on [NEW].\\
To close a tab just enter 'exit' like you'll close a terminal.
Openbox configuration
Now add the following lines to the <applications> section of ~/.config/openbox/rc.xml:
<application name="urxvtq"> <decor>no</decor> <position force="yes"> <x>center</x> <y>0</y> </position> <desktop>all</desktop> <layer>above</layer> <skip_pager>yes</skip_pager> <skip_taskbar>yes</skip_taskbar> <maximized>Horizontal</maximized> </application>
and add these lines to the <keyboard> section:
<keybind key="W-t"> <action name="Execute"> <command>/path/to/urxvtc</command> </action> </keybind> <keybind key="W-grave"> <action name="Execute"> <execute>/path/to/urxvtq</execute> </action> </keybind>
Here too you need to change the /path/to/* lines to point to the scripts that you saved above. Save the file and then reconfigure Openbox. You should now be able to launch regular instances of urxvt with the Windows/Super key + "t", and toggle the kuake-like console with Windows/Super+grave (`).
Further configuration
The advantage of this configuration over the urxvt kuake perl script is that Openbox provides more keybinding options such as modifier keys. The kuake script hijacks an entire physical key regardless of any modifier combination. Review the Openbox bindings documentation for the full range or possibilities.
The Openbox per-app settings can be used to further configure the behavior of the kuake-like console (e.g. screen position, layer, etc). You may need to change the "geometry" parameter in the urxvtq scriptlet to adjust the height of the console.
Related scripts
- hbekel has posted a generalized version of the urxvtq here which can be used to toggle any application using xdotool.
- http://www.jukie.net/~bart/blog/20070503013555 - A script for opening url's with your keyboard instead of mouse with urxvt.
Improving performance
- Avoid the use of Xft fonts. If Xft fonts must be used, append :antialias=false to the setting value.[4]
- Build rxvt-unicode with disabled support for unnecessary features, --disable-xft and --disable-unicode3 in particular.[5]
- Limit the number of saveLines (option -sl) in the scrollback buffer to reduce memory usage.[6]
- Consider running urxvtd as a daemon accepting connections from urxvtc clients.
External resources
- rxvt-unicode - Official site
- rxvt-unicode FAQ - Official FAQ
- rxvt-unicode Reference - Official manual page
- urxvtperl - Official Perl extension reference
- man urxvt