···11+#!/usr/bin/perl
22+#
33+# right-clicking on a filename in what looks like an `ls -l` listing will
44+# paste the escaped value of that filename
55+#
66+# Copyright (c) 2024 joshua stein <jcs@jcs.org>
77+#
88+# Permission to use, copy, modify, and distribute this software for any
99+# purpose with or without fee is hereby granted, provided that the above
1010+# copyright notice and this permission notice appear in all copies.
1111+#
1212+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1313+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1414+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1515+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1616+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1717+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1818+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1919+#
2020+2121+sub on_button_press {
2222+ my ($self, $event) = @_;
2323+2424+ if ($event->{button} == 3) {
2525+ my $line = $self->line($event->{row});
2626+ my $off = $line->offset_of($event->{row}, $event->{col});
2727+2828+ if ($line->t =~ /^[d-]......... .+? [A-Z][a-z][a-z] [\d ]\d (\d\d:\d\d| \d\d\d\d) (.+)/) {
2929+ if ($-[2] <= $off && $+[2] >= $off) {
3030+ $self->{term}->tt_write(quotemeta($2));
3131+ }
3232+ }
3333+3434+ return 1;
3535+ }
3636+3737+ ()
3838+}
+59
.urxvt/ext/warn_on_close
···11+#!/usr/bin/perl
22+#
33+# Copyright (c) 2025 joshua stein <jcs@jcs.org>
44+#
55+# Permission to use, copy, modify, and distribute this software for any
66+# purpose with or without fee is hereby granted, provided that the above
77+# copyright notice and this permission notice appear in all copies.
88+#
99+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1010+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1111+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1212+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1313+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1414+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1515+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1616+#
1717+1818+sub on_child_start {
1919+ my ($self, $pid) = @_;
2020+ $self->{shell_pid} = $pid;
2121+}
2222+2323+sub on_wm_delete_window {
2424+ my ($self, $event) = @_;
2525+2626+ # find tty of shell pid
2727+ my @tty = map { my $f = "/dev/" . $_; chomp($f); $f }
2828+ grep { !/^TTY/ }
2929+ `ps -o tty -p $self->{shell_pid}`;
3030+3131+ # find any other pids on this tty other than the shell
3232+ my @running = map { /^(\d+) (.+)/ ? $2 : () }
3333+ grep { /^\d+ / && !/^$self->{shell_pid} / }
3434+ `ps -t $tty[0] -o pid,command`;
3535+3636+ if ($#running > -1) {
3737+ open my $fh, "-|",
3838+ "Xdialog",
3939+ "--center",
4040+ "--title", "urxvt",
4141+ "--cancel-label", "No",
4242+ "--ok-label", "Yes",
4343+ "--yesno",
4444+ ($#running == 0 ? "Process" : "Processes") .
4545+ " still running here, close anyway?\\n\\n" .
4646+ join("\\n", @running),
4747+ scalar (12 + ($#running * 3)),
4848+ "100"
4949+ or die $!;
5050+ my $ret = close($fh);
5151+ if ($ret == 1) {
5252+ # successful close, i pressed ok, close window
5353+ return 0;
5454+ }
5555+ return 1;
5656+ }
5757+5858+ return 0;
5959+}