Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am a loyal Linux fan who has been spending a lot of time using iTerm on a mac lately. One thing I really like about the mac, and iTerm in particular, is the ability to use a keyboard shortcut to in/decrease the font size. I believe it's apple+ and apple- to do this. AFAIK this is also possible using gnome-terminal and possibly konqueror.

However, I am an rxvt-unicode user. Period. I'm not willing to switch my terminal, but I would like to be able to have the ability to quickly resize the font. Currently, to resize the font I have to do this:

  1. Detach tmux
  2. $EDITOR ~/.Xdefaults
  3. xrdb -all ~/.Xdefaults
  4. close terminal
  5. open a new terminal
  6. Reattach tmux

I'm thinking that it must be possible to script something that would reduce the above steps to one by perhaps binding to a keyboard shortcut, maybe with xbindkeys or something similar. Anyone have any thoughts on how this might best be accomplished?

Note: I'm using awesome window manager and prefer to keep things ultra-simple (i.e., no Gnome/KDE-specific solutions, please).

@Keith: I don't have enough rep to leave a comment, so an edit will have to do. I am familiar with the escape sequences and it's my fault for not saying so explicitly in my original question, but: I'm looking for a solution that will persist between sessions. Likely that will involve writing some code.

share|improve this question

2 Answers 2

From the man page:

CHANGING FONTS Changing fonts (or font sizes, respectively) via the keypad is not yet supported in rxvt-unicode. Bug me if you need this.

   You can, however, switch fonts at runtime using escape sequences,

e.g.:

      printf '\e]710;%s\007' "9x15bold,xft:Kochi Gothic"

   You can use keyboard shortcuts, too:

      URxvt.keysym.M-C-1: command:\033]710;suxuseuro\007\033]711;suxuseuro\007
      URxvt.keysym.M-C-2: command:\033]710;9x15bold\007\033]711;9x15bold\007

   rxvt-unicode will automatically re-apply these fonts to the output so

far.

Depending on the shell you use you could assign those to keyboard shortcuts. In zsh you could define a shell function and use bindkey to bind it to an alt-key for example.

share|improve this answer
    
Correct me if I'm wrong but this will not persist, right? –  g33kz0r Jun 6 '11 at 4:28
    
Sure it will. The keysym shortcuts you put in your ~/.Xdefaults file. If you use the shell functions and keybindings you put those in your ~/.zshrc (or whatever) file. –  Keith Jun 6 '11 at 4:32
    
I think we are defining "persist" differently. Your proposed solution of echoing escape sequences will not persist in a new process (new terminal window). See my (accepted) answer below for a solution that does "persist" in the sense that it outlives its parent process. –  g33kz0r Jul 6 '12 at 1:38
up vote 1 down vote accepted

I'm answering my own question (with code!) and upvoting Keith for his keysym suggestion. However, Keith's solution does not persist the resized font to the Xresources file, so that the resize is available when the next window is opened, whereas mine does:

https://github.com/noah/urxvt-font

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.