Compare commits
No commits in common. "bd5a149cc0d30b9695192e2065d3c291e1d21f6a" and "3e32f1b04eae521b29409ef201d77d8312b17d92" have entirely different histories.
bd5a149cc0
...
3e32f1b04e
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
prefix=$$HOME/opt/pkg/miscutils
|
||||
target_bin=${prefix}/bin
|
||||
target_man=${prefix}/share/man/man1
|
||||
bin=bwrap hppt mkgmap newp osc p rot rr scmfmt ts upcasetl unpage
|
||||
bin=bwrap hppt mkgmap newp rot rr scmfmt ts upcasetl unpage
|
||||
install:
|
||||
install -d ${target_bin} ${target_man}
|
||||
install -c ${bin} ${target_bin}
|
||||
|
18
osc
18
osc
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
(( $# < 1 )) && exit 64
|
||||
[[ -v X_OSC_DISABLE || ! -t 1 ]] && exit 0
|
||||
case $1 in
|
||||
link)
|
||||
[[ -z $2 ]] && exit 64
|
||||
printf "\e]8;%s\e\\" "$2"
|
||||
;;
|
||||
pwd)
|
||||
(( $# != 1 )) && exit 64
|
||||
printf "\e]7;file://%s%s\e\\" "$HOSTNAME" "$PWD"
|
||||
;;
|
||||
title)
|
||||
(( $# == 1 )) && exit 64
|
||||
shift;
|
||||
printf '\e]2;%s\e\\' "$*"
|
||||
;;
|
||||
esac
|
43
osc.1
43
osc.1
@ -1,43 +0,0 @@
|
||||
.Dd Jun 11, 2024
|
||||
.Dt TS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm osc
|
||||
.Nd Print OSC escape sequences
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Cm pwd
|
||||
.Nm
|
||||
.Cm link
|
||||
.Ar URI
|
||||
.Nm
|
||||
.Cm title
|
||||
.Ar word ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
prints an OSC escape sequence to stdout if connected to a tty.
|
||||
If stdout is not a TTY, prints nothing.
|
||||
.Pp
|
||||
Three escape sequences are supported:
|
||||
.Bl -tag
|
||||
.It pwd
|
||||
ESC 7, set current working directory.
|
||||
.It link
|
||||
ESC 8, display an URI.
|
||||
.It title
|
||||
ESC 2, set a title for the current window.
|
||||
.El
|
||||
.Pp
|
||||
Whatever it is done with these escape sequences depends on the
|
||||
terminal emulator. To avoid printing anything, even on ttys, define
|
||||
.Ev X_OSC_DISABLE
|
||||
with any value.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width X_OSC_DISABLE
|
||||
.It Ev X_OSC_DISABLE
|
||||
Don't do anything.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh AUTHORS
|
||||
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org
|
47
p
47
p
@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $pagesize = $ENV{'LINES'} || 22;
|
||||
|
||||
open(my $tty, '<', '/dev/tty')
|
||||
or die "$0: Cannot open /dev/tty for reading: $!";
|
||||
|
||||
sub evalcmd {
|
||||
{
|
||||
chomp($_ = <$tty>);
|
||||
if (/^q$/) {
|
||||
exit(0);
|
||||
} elsif (/^!(.*)/) {
|
||||
system($1);
|
||||
redo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub printfile {
|
||||
my ($fh) = @_;
|
||||
my $lines = 0;
|
||||
while (<$fh>) {
|
||||
print;
|
||||
&evalcmd unless ++$lines % $pagesize;
|
||||
}
|
||||
&evalcmd;
|
||||
}
|
||||
|
||||
unshift(@ARGV, '-') unless @ARGV;
|
||||
|
||||
for (@ARGV) {
|
||||
if (/^-$/) {
|
||||
&printfile(\*STDIN);
|
||||
} elsif (/^-(\d+)$/) {
|
||||
$pagesize = $1;
|
||||
} else {
|
||||
open(my $fh, '<', $_) or die "$0: Cannot open $_ for reading: $!";
|
||||
&printfile($fh);
|
||||
close($fh);
|
||||
}
|
||||
}
|
||||
|
||||
close($tty);
|
48
p.1
48
p.1
@ -1,48 +0,0 @@
|
||||
.Dd May 17, 2024
|
||||
.Dt TS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm p
|
||||
.Nd Paginate
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl number
|
||||
.Ar
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
copies its standard input, or the named files if given,
|
||||
to its standard output,
|
||||
stopping at the end of every page and at the end of each file.
|
||||
The special file name
|
||||
.Pa -
|
||||
can be used to refer explicitly to the standard input.
|
||||
.Pp
|
||||
Page size is defined by the
|
||||
.Ev LINES
|
||||
environment variable.
|
||||
If not defined, a default page size of 22 will be used.
|
||||
The page size can be overriden with the numeric option.
|
||||
.Pp
|
||||
While waiting for a newline,
|
||||
.Nm
|
||||
interprets the commands:
|
||||
.Bl -tag
|
||||
.It !
|
||||
Run the rest of the line as a shell command.
|
||||
.It q
|
||||
Quit.
|
||||
.El
|
||||
Any other input will show the next input page.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width LINES
|
||||
.It Ev LINES
|
||||
Number of lines of the terminal.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh HISTORY
|
||||
This is a reimplementation of Plan 9's
|
||||
.Nm
|
||||
pager.
|
||||
.Sh AUTHORS
|
||||
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org
|
Loading…
Reference in New Issue
Block a user