Urxvt Scrollback

So urxvt does this thing where your current screen is just deleted before being saved onto the scrollback buffer, which is fairly annoying for me because I clear my terminal a lot to keep things clutter free. So here’s the method that I use with zsh to psuedo-correctly clear my terminal under my settings

[[ "$TERM" =~ "rxvt-unicode" ]] && bindkey -s '^l' '^qurxvt-clear\n'
urxvt-clear()
{
  yes "" | head -`echo "$LINES - 1" | bc`; clear
}

bindkey -s binds a key to a string, ^l is control-l, and the ^q in the argument string does a zsh push-line, which clears the current line, writes what is next, and yanks back the deleted text after the command is run (can be stacked!!!), and this is only performed if $TERM is urxvt. I need $LINES-1 empty lines because my prompt is a two liner. YMMV.

This entry was posted in Software. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *