majutsushi / urxvt-font-size

Change the urxvt font size on the fly
Other
435 stars 46 forks source link

urxvt-font-size

This is a perl extension for rxvt-unicode that allows changing the font size on the fly with keyboard shortcuts. It has the following features:

Installation

Put the font-size script into $HOME/.urxvt/ext/ and add it to the list of enabled perl-extensions in ~/.Xresources:

URxvt.perl-ext-common: ...,font-size

Note: if your urxvt version is older than 9.14 you will have to add the path to the script to the URxvt.perl-lib resource.

The extension automatically binds Ctrl++ to the 'increase' function, Ctrl+- to 'decrease', and Ctrl+0 to 'reset'. To use the other available functions or change the keys, add some keybindings of your own:

URxvt.keysym.C-Up:     font-size:increase
URxvt.keysym.C-Down:   font-size:decrease
URxvt.keysym.C-S-Up:   font-size:incglobal
URxvt.keysym.C-S-Down: font-size:decglobal
URxvt.keysym.C-equal:  font-size:reset
URxvt.keysym.C-slash:  font-size:show

Then load your new ~/.Xresources to see the changes in the next terminal you open:

$ xrdb -merge ~/.Xresources

Note that for urxvt versions older than 9.21 the resources have to look like this:

URxvt.keysym.C-Up:     perl:font-size:increase
URxvt.keysym.C-Down:   perl:font-size:decrease
URxvt.keysym.C-S-Up:   perl:font-size:incglobal
URxvt.keysym.C-S-Down: perl:font-size:decglobal
URxvt.keysym.C-equal:  perl:font-size:reset
URxvt.keysym.C-slash:  perl:font-size:show

The following functions are supported:

You can also change the step size that the script will use to increase the font size:

URxvt.font-size.step: 4

The default step size is 1. This means that with this setting a size change sequence would be for example 8->12->16->20 instead of 8->9->10->11->12 etc. Please note that many X11 fonts are only available in specific sizes, though, and odd sizes are often not available, resulting in an effective step size of 2 instead of 1 in that case.

Troubleshooting

At its core urxvt-font-size is just a fancy wrapper around the ESC ] 710;Pt ST (and 711/712/713 for bold, italic, and bold-italic) escape sequences. So if you are having trouble with this script please try the escape sequence directly like this (outside of a terminal multiplexer like screen or tmux):

$ echo -e "\033]710;fixed\033\\"

You can exchange fixed for any (single) font that you want to try, like for example -xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso10646-1:

$ echo -e "\033]710;-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso10646-1\033\\"

If you can reproduce the problem this way then the problem does not lie with the urxvt-font-size script, but either directly with urxvt or some other component that may interfere (like for example a window manager). Please report the bug to those projects in that case.