urxvtperl: paste a part of the previous line
Raph
gibboris at gmail.com
Thu Dec 29 16:58:06 CET 2011
I post this in case it gives some ideas about possible enhancements in
the terminal daily use.
One thing I do quite often and which implies mouse movements is cutting &
pasting a selection. I feel bad when it happens within the same terminal.
The most common case is when I want to use the part of the output of a
previous command (like a search), eg:
$ `find|locate|grep` <something>
then
$ `edit|view` <the pathname of the last match>.
The attached (very simple) extension and something like the following:
> urxvtterm.keysym.M-S-V: perl:yank-return:true
should be a good start so one can do:
$ grep yank ~/.urxvt/*
~/.urxvt/yank-return: if ($cmd eq "yank-return:true") {
$ nano <Alt-Shift-V><Enter>
# to edit the above file
There are some missing bits (like regexp configuration) but most of all
one big gotcha: inability to know what the previous command was (that's
shell/readline stuff) => impossibility to react according to this or to
detect consistently if the previous line was empty, was the prompt, ...
I believe that this kind of key-bindings belongs to the shell itself
rather than readline or urxvt, but the above extension works
sufficiently for me.
long life urxvtperl
Raph
-------------- next part --------------
#! perl
sub on_user_command {
my ($self, $cmd) = @_;
if ($cmd eq "yank-return:true") {
my ($row, $col) = $self->screen_cur;
my $line = $self->ROW_t ($row - 1);
if ($line =~ /:/) {
$line =~ s/^([^:[:space:]]+):.*$/$1/;
$self->tt_write($line);
}
}
()
}
More information about the rxvt-unicode
mailing list