mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-03 03:37:36 +00:00
feat(cli): add mtime-sort utility, enhance pj task runner, and remove legacy executable_gho
This commit is contained in:
1 parent
1d1f0be08b
commit
f033b29a7d
3 files changed
+121
-115
No files matched your search
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Sort stdin lines newest-first by mtime — the base order of the television
|
||||
# cables (tv then layers match quality and frecency on top).
|
||||
#
|
||||
# The path is each line's last tab-separated field (the whole line when it
|
||||
# has no tab). With --repo, <path>/.git/index is stat'ed first, so a repo
|
||||
# ranks by its last git activity rather than its directory mtime. Lines whose
|
||||
# path does not exist are dropped; ties keep their input order.
|
||||
#
|
||||
# Usage: <lines> | mtime-sort [--repo]
|
||||
exec perl -e '
|
||||
my $repo = @ARGV && $ARGV[0] eq "--repo";
|
||||
my ($i, @rows) = (0);
|
||||
while (my $line = <STDIN>) {
|
||||
chomp $line;
|
||||
my $path = (split /\t/, $line)[-1];
|
||||
next unless defined $path && length $path;
|
||||
my $mtime;
|
||||
$mtime = (stat "$path/.git/index")[9] if $repo;
|
||||
$mtime = (stat $path)[9] unless defined $mtime;
|
||||
push @rows, [$mtime, $i++, $line] if defined $mtime;
|
||||
}
|
||||
print "$_->[2]\n" for sort { $b->[0] <=> $a->[0] || $a->[1] <=> $b->[1] } @rows;
|
||||
' -- "$@"
|
||||
Reference in new issue
Block a user