DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

URxvt Notes


Install rxvt-unicode (or urxvt for short) with apt install rxvt-unicode. rxvt is acronym for ouR eXtended Virtual Terminator.

Color Customization

Add the following codes into ~/.Xdefaults:

!! Colorscheme

! special
*.foreground: #93a1a1
*.background: #141c21
*.cursorColor: #afbfbf

! black
*.color0: #263640
*.color8: #4a697d

! red
*.color1: #d12f2c
*.color9: #fa3935

! green
*.color2: #819400
*.color10: #a4bd00

! yellow
*.color3: #b08500
*.color11: #d9a400

! blue
*.color4: #2587cc
*.color12: #2ca2f5

! magenta
*.color5: #696ebf
*.color13: #8086e8

! cyan
*.color6: #289c93
*.color14: #33c5ba

! white
*.color7: #bfbaac
*.color15: #fdf6e3

Add a icon

Add the following lines into ~/.Xdefaults:

URxvt.iconFile: /usr/share/icons/gnome/scalable/apps/utilities-terminal-symbolic.svg

Make sure the file exists on your OS. Verified on Linux Mint 19.

Font Customization

Try a font with urxvt -fn "xft:DejaVu Sans Mono".

Add the following codes into ~/.Xdefaults:

URxvt.font: xft:DejaVu Sans Mono:size=10,xft:WenQuanYi Micro Hei Mono:antialias=true:size=10

Copy and Paste

Add keyboard-selection extension:

mkdir -p ~/.urxvt/ext
curl https://raw.githubusercontent.com/muennich/urxvt-perls/master/keyboard-select -o ~/.urxvt/ext/keyboard-select
cat << EOF >> ~/.Xdefaults

URxvt.perl-ext-common: default,keyboard-select
URxvt.keysym.M-Escape: perl:keyboard-select:activate
URxvt.keyboard-select.clipboard: true

EOF

Now you can use Alt-Escape to activate keyboard-selection mode. Then use all vi keys to move, select and copy. Finally use q to quit selection mode.

Use Alt-Ctrl-v to paste from system clipboard to urxvt.

See urxvt-perls for details.

Window Control

Full Screen

Toggle fullscreen with key:

sudo apt-get install wmctrl

cat << EOF > ~/.urxvt/ext/fullscreen
#!perl
sub on_user_command {
    my ($self, $cmd) = @_;
    if ($cmd eq "fullscreen:switch") {
        my $dummy = `wmctrl -r :ACTIVE: -b toggle,fullscreen` ;
    }
}
EOF

cat << EOF >> ~/.Xdefaults
! FullScreen
URxvt.perl-ext-common:  fullscreen
URxvt.keysym.F11:       perl:fullscreen:switch
EOF

Maximize Window when Startup

The format of geometry is <row>x<column>+X+Y. You have to test your row and column carefully according to your screen size. If it's too large, the X and Y will failed.

cat << EOF >> ~/.Xdefaults
URxvt.geometry: 151x41+0+0
EOF

Input Method

Add the following lines into ~/.Xdefaults:

URxvt*inputMethod: fcitx
URxvt.imLocale: en_US.UTF-8

Change fcitx to ibus if your input method is IBus.

Ref: https://github.com/posquit0/dotfiles/blob/master/X/.Xresources.d/urxvt

User Defined Perl Extension

cat << EOF > ~/.urxvt/ext/select-warnning
sub on_sel_grab {
  warn "you selected ", $_[0]->selection;
  ()
}
EOF
urxvt -pe select-warnning  # in window A, start a new urxvt window B

Now when you select some texts in urxvt window B with mouse, you can see these texts in window A.



Published

Jan 13, 2020

Last Updated

Apr 20, 2020

Category

Tech

Tags

  • terminal emulator 1
  • urxvt 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor