rxvt-unicode/Tips and tricks
See rxvt-unicode for the main article.
Improved Kuake-like behavior in Openbox
This was originally posted on the forum by Xyne [1], and it relies on the xdotool found in the official repositories.
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 --classname urxvtq) if [ -z "$wid" ]; then /path/to/urxvtc -name urxvtq -geometry 80x28 wid=$(xdotool search --classname urxvtq | head -1) xdotool windowfocus "$wid" xdotool key Control_L+l else if [ -z "$(xdotool search --onlyvisible --classname 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 will 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 --classname urxvtq)
with:
wid=$(xdotool search --classname urxvtq | grep -m 1 "" )
To activate 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 ~/.Xresources
file:
URxvt.perl-ext-common: default,matcher
with
URxvt.perl-ext-common: default,matcher,tabbed
Tab control
Key | Description |
---|---|
Shift+Left | Switch to the tab left of the current one |
Shift+Right | Switch to the tab right of the 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 would to normally 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 Super+T
, and toggle the kuake-like console with Super+`
(the grave key also known as the backtick).
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 URLs 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.[2] - Build rxvt-unicode with disabled support for unnecessary features,
--disable-xft
and--disable-unicode3
in particular.[3] - Limit the number of
saveLines
(option-sl
) in the scrollback buffer to reduce memory usage. [4]- Use tmux for scrollback buffer and set saveLines to 0
- Disable perl
- Consider running
urxvtd
as a daemon accepting connections fromurxvtc
clients.
Daemon-client
Xinitrc
See the Examples section in urxvtd(1). This is the preferred option.
systemd
System service:
/etc/systemd/system/urxvtd@.service
[Unit] Description=RXVT-Unicode Daemon [Service] User=%i ExecStart=/usr/bin/urxvtd -q -o [Install] WantedBy=multi-user.target
Pass the username when starting the service:
urxvtd@username.service
For a systemd/User service, place the following unit files in ~/.config/systemd/user
:
urxvtd.service
[Unit] Description=Urxvt Terminal Daemon Requires=urxvtd.socket [Service] ExecStart=/usr/bin/urxvtd -o -q Environment=RXVT_SOCKET=%t/urxvtd-%H [Install] Also=urxvtd.socket WantedBy=MyTarget.target
urxvtd.socket
[Unit] Description=urxvt daemon (socket activation) Documentation=man:urxvtd(1) man:urxvt(1) [Socket] ListenStream=%t/urxvtd-%H [Install] WantedBy=sockets.target
Advanced tab management
Install the urxvt-tabbedexAUR package from AUR, then add the tabbedex
value to the URxvt.perl-ext-common
X resource in your ~/.Xresources
:
URxvt.perl-ext-common: ...,tabbedex,...
tabbed
Perl extension and have defined the tabbed
value for the URxvt.perl-ext-common
X resource, please remove the tabbed
value first to avoid conflict with tabbedex
.By default, the "[NEW]" button (which is rarely used and usable only with the mouse) is disabled with tabbedex. You can reenable this feature by setting the new-button
to true.
URxvt.tabbed.new-button: true
Tabs can be named with Shift+ ↑
(Enter
to confirm, Escape
to cancel).
To automatically hide the tabs bar when only one tab is present, enable the following resource:
URxvt.tabbed.autohide: true
To prevent the last tab from closing Urxvt, enable the following resource:
URxvt.tabbed.reopen-on-close: yes
To start a new tab or cycle through tabs, use the following user commands: tabbedex:(new|next|prev)_tab
. Example of mappings:
URxvt.keysym.Control-t: perl:tabbedex:new_tab URxvt.keysym.Control-Tab: perl:tabbedex:next_tab URxvt.keysym.Control-Shift-Tab: perl:tabbedex:prev_tab
To define your own key bindings to rename a tab or move a tab to the right or to the left, use the following commands: tabbedex:move_tab_(left|right)
and tabbedex:rename_tab
. Example of mappings:
URxvt.keysym.Control-Shift-Left: perl:tabbedex:move_tab_left URxvt.keysym.Control-Shift-Right: perl:tabbedex:move_tab_right URxvt.keysym.Control-Shift-R: perl:tabbedex:rename_tab
no-tabbedex-keys
for that:
URxvt.tabbed.no-tabbedex-keys: true
Transparency
True transparency
To use true transparency, you need to be using a window manager that supports compositing or a separate compositor.
From the command-line:
$ urxvt -depth 32 -bg rgba:3f00/3f00/3f00/dddd
Using the configuration file:
~/.Xresources
URxvt.depth: 32 URxvt.background: rgba:1111/1111/1111/dddd
or
~/.Xresources
URxvt.depth: 32 URxvt.background: [95]#000000
where '95' is the opacity level in percentage and '#000000' is the background color.
To use a color i.e. #302351 with the rgba:rrrr/gggg/bbbb/aaaa syntax it would be rgba:3000/2300/5100/ee00. "ee00" (the alpha value) to make it nicely transparent.
URxvt.depth
would become URxvt*depth
.Native transparency
If there is no need for true transparency, or if compositing uses too many resources on your system, you can get transparency working in the following way:
~/.Xresources
! Xresources file URxvt*inheritPixmap: true URxvt*transparent: true ! URxvt*shading: 0 to 99 darkens, 101 to 200 lightens URxvt*shading: 110
Using the URxvt*background setting exemplified above instead of URxvt*shading will also work.
URxvt.tintColor
set. Use a different tintColor
instead.Set icon
By default URxvt does not feature a taskbar icon. However, this can be easily changed by adding the following line to ~/.Xresources
and pointing to the desired icon:
URxvt.iconFile: /usr/share/icons/Clarity/scalable/apps/terminal.svg
Use urxvt as application launcher
urxvt can be used as a lightweight alternative to application launchers such as gmrun. Run urxvt with the following configuration to imitate look and behaviour of an application launcher or assign the command to a custom alias:
$ urxvt -geometry 80x3 -name 'bashrun' -e sh -c "/bin/bash -i -t"
Xterm escape sequences
It is possible for rxvt-unicode to mimic the Xterm escape sequences. These can be found for arbitrary key combinations by running cat -v
inside xterm, then bound in urxvt using keysyms.
Take this word by word movement binding as an example:
~/.Xresources
!Xterm escapes, word by word movement URxvt.keysym.Control-Left: \033[1;5D URxvt.keysym.Control-Right: \033[1;5C
For more information, see ascii(7) and the keysym section of the urxvt(1) man page.
Bidirectional support
It is possible to add bidirectional support for languages like Hebrew or Arabic using the bidi extension.
Bell Command
It is possible to execute a shell command when the terminal rings the bell. The pre-packed bell-command
extension needs to be enabled first in the ~/.Xresources
file:
URxvt.perl-ext-common: ...,bell-command,...
The following example will use ALSA's aplay
command to play a .wav
file:
URxvt.bell-command: aplay /path/to/a/file.wav
The following example will use libcanberra's canberra-gtk-play
command to play the bell sound of your current sound theme:
URxvt.bell-command: canberra-gtk-play -i bell
And the next setting will pop a visual notification:
URxvt.bell-command: notify-send "rxvt-unicode: bell!"
bell-command
option alone will not mute the buzzer in your computer, to do that take a look at the PC speaker article.