-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
pilsner
executable file
·79 lines (70 loc) · 2.53 KB
/
pilsner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
# abstract: what later turned into ls++
# Copyright (C) 2010 Magnus Woldrich <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################
use strict;
use Data::Dumper;
@ARGV = map{"'$_'"} @ARGV; # escape bad chars
open(my $l, "ls -hAlv --group-directories-first --color=always @ARGV|")
or die($!);
chomp(my @ls = grep{!/total.+/} (<$l>));
my($fg,$bg,$bold,$def) = ("\e[38;5", "\e[48;5", "\e[1m", "\e[0m");
for(@ls) {
my ($perm,$hlink,$user,$group,$size,$month,$day,$time,$file) =
split(/\s+/, $_,8);
# dead fugly
my($file) = $_ =~ m/\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+ (.+)/;
my @perms = split(//, $perm);
for(@perms) {
$_ = "$bold$fg;240m‐$def" if($_ eq '-');
$_ = "$bold$fg;032m$_$def" if($_ eq 'd');
$_ = "$bold$fg;060m$_$def" if($_ eq 'l');
$_ = "$bold$fg;197m$_$def" if($_ eq 's');
$_ = "$bold$fg;127m$_$def" if($_ eq 'p');
$_ = "$bold$fg;221m$_$def" if($_ eq 'S');
$_ = "$bold$fg;226m$_$def" if($_ eq 't');
$_ = "$bold$fg;220m$_$def" if($_ eq 'T');
$_ = "$fg;185m$_$def" if($_ eq 'r');
$_ = "$fg;215m$_$def" if($_ eq 'w');
$_ = "$fg;209m$_$def" if($_ eq 'x');
}
$perm = join('', @perms);
my($left_delimiter, $right_delimiter);
if($file =~ /.+\.pl/) {
$right_delimiter = "\e[38;5;178m▏\e[0m";
$left_delimiter = "\e[38;5;240m▕\e[0m";
}
else {
$right_delimiter = "\e[38;5;240m▏\e[0m";
$left_delimiter = "\e[38;5;240m▕\e[0m";
}
if($file =~ /\.un~/) {
next;
}
if($file =~ /\..*rc/) {
$file = "\e[38;5;106m$file\e[0m";
}
if($file eq 'README') {
$file = "\e[1m\e[38;5;26m$file\e[0m";
}
if($file eq 'Makefile') {
$file = "\e[1m\e[38;5;124m$file\e[0m";
}
$file =~ s/-> (.+)/$fg;160m▪▶$def $fg;197m$1$def/;
printf("$fg;235m%02d $bold$fg;240m%s$def$left_delimiter%s$right_delimiter$def%s\n",
$day, $month, $perm, $file);
}
exit(0);