| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::LsColor; |
|
2
|
2
|
|
|
2
|
|
118906
|
use strict; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
63
|
|
|
3
|
|
|
|
|
|
|
#use warnings; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
|
6
|
2
|
|
|
2
|
|
8
|
use Exporter; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
66
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
258
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8
|
$VERSION = '0.520'; |
|
10
|
2
|
|
|
|
|
34
|
@ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
7
|
@EXPORT_OK = qw( |
|
13
|
|
|
|
|
|
|
ls_color |
|
14
|
|
|
|
|
|
|
ls_color_custom |
|
15
|
|
|
|
|
|
|
ls_color_default |
|
16
|
|
|
|
|
|
|
ls_color_internal |
|
17
|
|
|
|
|
|
|
get_ls_colors |
|
18
|
|
|
|
|
|
|
can_ls_color |
|
19
|
|
|
|
|
|
|
ls_color_lookup |
|
20
|
|
|
|
|
|
|
parse_ls_colors |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
108
|
%EXPORT_TAGS = ( |
|
24
|
|
|
|
|
|
|
all => [ |
|
25
|
|
|
|
|
|
|
qw( |
|
26
|
|
|
|
|
|
|
ls_color ls_color_custom ls_color_default ls_color_internal |
|
27
|
|
|
|
|
|
|
get_ls_colors can_ls_color ls_color_lookup parse_ls_colors |
|
28
|
|
|
|
|
|
|
) |
|
29
|
|
|
|
|
|
|
], |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Skip stat:ing files for attributes like +x. This can be desired if the |
|
34
|
|
|
|
|
|
|
# filenames aren't real files, or for performance reasons. |
|
35
|
|
|
|
|
|
|
our $NO_STAT = 0; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# If true, ignore case on file extensions; mp4/MP4 |
|
38
|
|
|
|
|
|
|
our $IGNORE_CASE = 0; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# alias for compatibility reasons with File::LsColor prior to 0.300 |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
2
|
|
|
2
|
|
11
|
no warnings 'once'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
105
|
|
|
43
|
|
|
|
|
|
|
*ls_color_lookup = *can_ls_color; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#use Carp qw(croak); |
|
47
|
2
|
|
|
2
|
|
1004
|
use Term::ExtendedColor qw(fg); |
|
|
2
|
|
|
|
|
4514
|
|
|
|
2
|
|
|
|
|
1829
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#
|
|
51
|
|
|
|
|
|
|
# yes, this is pretty :) |
|
52
|
|
|
|
|
|
|
# colors from https://github.com/trapd00r/LS_COLORS |
|
53
|
|
|
|
|
|
|
my $internal_ls_color=' |
|
54
|
|
|
|
|
|
|
bd=38;5;68:ca=38;5;17:cd=38;5;113;1:di=38;5;30:do=38;5;127:ex=38;5;166;1: |
|
55
|
|
|
|
|
|
|
pi=38;5;126:fi=38;5;253:ln=target:mh=38;5;222;1:or=48;5;196;38;5;232;1: |
|
56
|
|
|
|
|
|
|
ow=38;5;220;1:sg=48;5;3;38;5;0:su=38;5;220;1;3;100;1:so=38;5;197: |
|
57
|
|
|
|
|
|
|
st=38;5;232;48;5;30:tw=48;5;235;38;5;139;3:*LS_COLORS=48;5;89;38;5;197;1;3;4;7: |
|
58
|
|
|
|
|
|
|
*.msi=38;5;039:*.xys=38;5;204:*README=38;5;220;1:*LICENSE=38;5;220;1: |
|
59
|
|
|
|
|
|
|
*COPYING=38;5;220;1:*INSTALL=38;5;220;1:*COPYRIGHT=38;5;220;1: |
|
60
|
|
|
|
|
|
|
*AUTHORS=38;5;220;1:*HISTORY=38;5;220;1:*CONTRIBUTORS=38;5;220;1: |
|
61
|
|
|
|
|
|
|
*PATENTS=38;5;220;1:*VERSION=38;5;220;1:*NOTICE=38;5;220;1:*CHANGES=38;5;220;1: |
|
62
|
|
|
|
|
|
|
*.log=38;5;190:*Makefile=38;5;155:*MANIFEST=38;5;243:*pm_to_blib=38;5;240: |
|
63
|
|
|
|
|
|
|
*.txt=38;5;253:*.etx=38;5;184:*.info=38;5;184:*.markdown=38;5;184:*.md=38;5;184: |
|
64
|
|
|
|
|
|
|
*.mkd=38;5;184:*.nfo=38;5;184:*.pod=38;5;184:*.tex=38;5;184:*.textile=38;5;184: |
|
65
|
|
|
|
|
|
|
*.json=38;5;178:*.msg=38;5;178:*.pgn=38;5;178:*.rss=38;5;178:*.xml=38;5;178: |
|
66
|
|
|
|
|
|
|
*.yml=38;5;178:*.RData=38;5;178:*.rdata=38;5;178:*.csv=38;5;78:*.cbr=38;5;141: |
|
67
|
|
|
|
|
|
|
*.cbz=38;5;141:*.chm=38;5;141:*.djvu=38;5;141:*.pdf=38;5;141:*.PDF=38;5;141: |
|
68
|
|
|
|
|
|
|
*.docm=38;5;111;4:*.doc=38;5;111:*.docx=38;5;111:*.eps=38;5;111:*.ps=38;5;111: |
|
69
|
|
|
|
|
|
|
*.odb=38;5;111:*.odt=38;5;111:*.odp=38;5;166:*.pps=38;5;166:*.ppt=38;5;166: |
|
70
|
|
|
|
|
|
|
*.ods=38;5;112:*.xla=38;5;76:*.xls=38;5;112:*.xlsx=38;5;112:*.xlsxm=38;5;112;4: |
|
71
|
|
|
|
|
|
|
*.xltm=38;5;73;4:*.xltx=38;5;73:*cfg=38;5;204:*conf=38;5;204:*rc=38;5;204: |
|
72
|
|
|
|
|
|
|
*.ini=38;5;204:*.gws=38;5;204:*.viminfo=38;5;204:*.pcf=38;5;204:*.psf=38;5;204: |
|
73
|
|
|
|
|
|
|
*.reg=38;5;203:*.git=38;5;197:*.gitignore=38;5;240:*.gitattributes=38;5;240: |
|
74
|
|
|
|
|
|
|
*.gitmodules=38;5;240:*.awk=38;5;172:*.bash=38;5;172:*.bat=38;5;172: |
|
75
|
|
|
|
|
|
|
*.BAT=38;5;172:*.sed=38;5;172:*.sh=38;5;138:*.zsh=38;5;137:*.vim=38;5;254;1: |
|
76
|
|
|
|
|
|
|
*.ahk=38;5;41:*.py=38;5;41:*.pl=38;5;208:*.PL=38;5;160:*.t=38;5;114: |
|
77
|
|
|
|
|
|
|
*.msql=38;5;222:*.mysql=38;5;222:*.pgsql=38;5;222:*.sql=38;5;222: |
|
78
|
|
|
|
|
|
|
*.tcl=38;5;64;1:*.r=38;5;49:*.R=38;5;49:*.gs=38;5;81:*.asm=38;5;81: |
|
79
|
|
|
|
|
|
|
*.cl=38;5;81:*.lisp=38;5;81:*.lua=38;5;81:*.moon=38;5;81:*.c=38;5;81: |
|
80
|
|
|
|
|
|
|
*.C=38;5;81:*.h=38;5;110:*.H=38;5;110:*.tcc=38;5;110:*.c++=38;5;81: |
|
81
|
|
|
|
|
|
|
*.h++=38;5;110:*.hpp=38;5;110:*.hxx=38;5;110:*.ii=38;5;110:*.M=38;5;110: |
|
82
|
|
|
|
|
|
|
*.m=38;5;110:*.cc=38;5;81:*.cs=38;5;81:*.cp=38;5;81:*.cpp=38;5;81:*.cxx=38;5;81: |
|
83
|
|
|
|
|
|
|
*.cr=38;5;81:*.go=38;5;81:*.f=38;5;81:*.for=38;5;81:*.ftn=38;5;81:*.s=38;5;110: |
|
84
|
|
|
|
|
|
|
*.S=38;5;110:*.rs=38;5;81:*.sx=38;5;81:*.hi=38;5;110:*.hs=38;5;81:*.lhs=38;5;81: |
|
85
|
|
|
|
|
|
|
*.pyc=38;5;240:*.css=38;5;125;1:*.less=38;5;125;1:*.sass=38;5;125;1: |
|
86
|
|
|
|
|
|
|
*.scss=38;5;125;1:*.htm=38;5;125;1:*.html=38;5;125;1:*.jhtm=38;5;125;1: |
|
87
|
|
|
|
|
|
|
*.mht=38;5;125;1:*.eml=38;5;125;1:*.mustache=38;5;125;1:*.coffee=38;5;074;1: |
|
88
|
|
|
|
|
|
|
*.java=38;5;074;1:*.js=38;5;074;1:*.jsm=38;5;074;1:*.jsm=38;5;074;1: |
|
89
|
|
|
|
|
|
|
*.jsp=38;5;074;1:*.php=38;5;81:*.ctp=38;5;81:*.twig=38;5;81:*.vb=38;5;81: |
|
90
|
|
|
|
|
|
|
*.vba=38;5;81:*.vbs=38;5;81:*.am=38;5;242:*.in=38;5;242:*.hin=38;5;242: |
|
91
|
|
|
|
|
|
|
*.scan=38;5;242:*.m4=38;5;242:*.old=38;5;242:*.out=38;5;242:*.SKIP=38;5;244: |
|
92
|
|
|
|
|
|
|
*.diff=48;5;197;38;5;232:*.patch=48;5;197;38;5;232;1:*.bmp=38;5;129: |
|
93
|
|
|
|
|
|
|
*.tiff=38;5;97:*.TIFF=38;5;97:*.cdr=38;5;97:*.gif=38;5;97:*.ico=38;5;132: |
|
94
|
|
|
|
|
|
|
*.jpeg=38;5;125:*.JPG=38;5;125:*.jpg=38;5;125:*.nth=38;5;97:*.png=38;5;197: |
|
95
|
|
|
|
|
|
|
*.svg=38;5;97:*.xpm=38;5;97:*.avi=38;5;114:*.divx=38;5;114:*.IFO=38;5;114: |
|
96
|
|
|
|
|
|
|
*.m2v=38;5;114:*.m4v=38;5;114:*.mkv=38;5;114:*.MOV=38;5;114:*.mov=38;5;114: |
|
97
|
|
|
|
|
|
|
*.mp4=38;5;114:*.mpeg=38;5;114:*.mpg=38;5;114:*.ogm=38;5;114:*.rmvb=38;5;114: |
|
98
|
|
|
|
|
|
|
*.sample=38;5;114:*.wmv=38;5;114:*.3g2=38;5;115:*.3gp=38;5;115:*.gp3=38;5;115: |
|
99
|
|
|
|
|
|
|
*.webm=38;5;115:*.gp4=38;5;115:*.asf=38;5;115:*.flv=38;5;115:*.ts=38;5;115: |
|
100
|
|
|
|
|
|
|
*.ogv=38;5;115:*.f4v=38;5;115:*.VOB=38;5;115;1:*.vob=38;5;115;1: |
|
101
|
|
|
|
|
|
|
*.3ga=38;5;137;1:*.S3M=38;5;137;1:*.aac=38;5;137;1:*.dat=38;5;137;1: |
|
102
|
|
|
|
|
|
|
*.dts=38;5;137;1:*.fcm=38;5;137;1:*.m4a=38;5;137;1:*.mid=38;5;137;1: |
|
103
|
|
|
|
|
|
|
*.midi=38;5;137;1:*.mod=38;5;137;1:*.mp3=38;5;137;1:*.oga=38;5;137;1: |
|
104
|
|
|
|
|
|
|
*.ogg=38;5;137;1:*.s3m=38;5;137;1:*.sid=38;5;137;1:*.ape=38;5;136;1: |
|
105
|
|
|
|
|
|
|
*.flac=38;5;136;1:*.alac=38;5;136;1:*.wav=38;5;136;1:*.wv=38;5;136;1: |
|
106
|
|
|
|
|
|
|
*.wvc=38;5;136;1:*.afm=38;5;66:*.pfb=38;5;66:*.pfm=38;5;66:*.ttf=38;5;66: |
|
107
|
|
|
|
|
|
|
*.otf=38;5;66:*.PFA=38;5;66:*.pfa=38;5;66:*.7z=38;5;40:*.a=38;5;40: |
|
108
|
|
|
|
|
|
|
*.arj=38;5;40:*.bz2=38;5;40:*.gz=38;5;40:*.rar=38;5;40:*.tar=38;5;40: |
|
109
|
|
|
|
|
|
|
*.tgz=38;5;40:*.xz=38;5;40:*.zip=38;5;40:*.r00=38;5;239:*.r01=38;5;239: |
|
110
|
|
|
|
|
|
|
*.r02=38;5;239:*.r03=38;5;239:*.r04=38;5;239:*.r05=38;5;239:*.r06=38;5;239: |
|
111
|
|
|
|
|
|
|
*.r07=38;5;239:*.r08=38;5;239:*.r09=38;5;239:*.r10=38;5;239:*.r100=38;5;239: |
|
112
|
|
|
|
|
|
|
*.r101=38;5;239:*.r102=38;5;239:*.r103=38;5;239:*.r104=38;5;239: |
|
113
|
|
|
|
|
|
|
*.r105=38;5;239:*.r106=38;5;239:*.r107=38;5;239:*.r108=38;5;239: |
|
114
|
|
|
|
|
|
|
*.r109=38;5;239:*.r11=38;5;239:*.r110=38;5;239:*.r111=38;5;239:*.r112=38;5;239: |
|
115
|
|
|
|
|
|
|
*.r113=38;5;239:*.r114=38;5;239:*.r115=38;5;239:*.r116=38;5;239:*.r12=38;5;239: |
|
116
|
|
|
|
|
|
|
*.r13=38;5;239:*.r14=38;5;239:*.r15=38;5;239:*.r16=38;5;239:*.r17=38;5;239: |
|
117
|
|
|
|
|
|
|
*.r18=38;5;239:*.r19=38;5;239:*.r20=38;5;239:*.r21=38;5;239:*.r22=38;5;239: |
|
118
|
|
|
|
|
|
|
*.r25=38;5;239:*.r26=38;5;239:*.r27=38;5;239:*.r28=38;5;239:*.r29=38;5;239: |
|
119
|
|
|
|
|
|
|
*.r30=38;5;239:*.r31=38;5;239:*.r32=38;5;239:*.r33=38;5;239:*.r34=38;5;239: |
|
120
|
|
|
|
|
|
|
*.r35=38;5;239:*.r36=38;5;239:*.r37=38;5;239:*.r38=38;5;239:*.r39=38;5;239: |
|
121
|
|
|
|
|
|
|
*.r40=38;5;239:*.r41=38;5;239:*.r42=38;5;239:*.r43=38;5;239:*.r44=38;5;239: |
|
122
|
|
|
|
|
|
|
*.r45=38;5;239:*.r46=38;5;239:*.r47=38;5;239:*.r48=38;5;239:*.r49=38;5;239: |
|
123
|
|
|
|
|
|
|
*.r50=38;5;239:*.r51=38;5;239:*.r52=38;5;239:*.r53=38;5;239:*.r54=38;5;239: |
|
124
|
|
|
|
|
|
|
*.r55=38;5;239:*.r56=38;5;239:*.r57=38;5;239:*.r58=38;5;239:*.r59=38;5;239: |
|
125
|
|
|
|
|
|
|
*.r60=38;5;239:*.r61=38;5;239:*.r62=38;5;239:*.r63=38;5;239:*.r64=38;5;239: |
|
126
|
|
|
|
|
|
|
*.r65=38;5;239:*.r66=38;5;239:*.r67=38;5;239:*.r68=38;5;239:*.r69=38;5;239: |
|
127
|
|
|
|
|
|
|
*.r69=38;5;239:*.r70=38;5;239:*.r71=38;5;239:*.r72=38;5;239:*.r73=38;5;239: |
|
128
|
|
|
|
|
|
|
*.r74=38;5;239:*.r75=38;5;239:*.r76=38;5;239:*.r77=38;5;239:*.r78=38;5;239: |
|
129
|
|
|
|
|
|
|
*.r79=38;5;239:*.r80=38;5;239:*.r81=38;5;239:*.r82=38;5;239:*.r83=38;5;239: |
|
130
|
|
|
|
|
|
|
*.r84=38;5;239:*.r85=38;5;239:*.r86=38;5;239:*.r87=38;5;239:*.r88=38;5;239: |
|
131
|
|
|
|
|
|
|
*.r89=38;5;239:*.r90=38;5;239:*.r91=38;5;239:*.r92=38;5;239:*.r93=38;5;239: |
|
132
|
|
|
|
|
|
|
*.r94=38;5;239:*.r95=38;5;239:*.r96=38;5;239:*.r97=38;5;239:*.r98=38;5;239: |
|
133
|
|
|
|
|
|
|
*.r99=38;5;239:*.apk=38;5;215:*.deb=38;5;215:*.jad=38;5;215:*.jar=38;5;215: |
|
134
|
|
|
|
|
|
|
*.cab=38;5;215:*.pak=38;5;215:*.pk3=38;5;215:*.vdf=38;5;215:*.vpk=38;5;215: |
|
135
|
|
|
|
|
|
|
*.bsp=38;5;215:*.dmg=38;5;215:*.iso=38;5;124:*.bin=38;5;124:*.nrg=38;5;124: |
|
136
|
|
|
|
|
|
|
*.qcow=38;5;124:*.sparseimage=38;5;124:*.accdb=38;5;60:*.accde=38;5;60: |
|
137
|
|
|
|
|
|
|
*.accdr=38;5;60:*.accdt=38;5;60:*.db=38;5;60:*.localstorage=38;5;60: |
|
138
|
|
|
|
|
|
|
*.sqlite=38;5;60:*.typelib=38;5;60:*.nc=38;5;60:*.part=38;5;239:*~=38;5;241: |
|
139
|
|
|
|
|
|
|
*.pacnew=38;5;33:*.un~=38;5;241:*.orig=38;5;241:*.BUP=38;5;241:*.bak=38;5;241: |
|
140
|
|
|
|
|
|
|
*.o=38;5;241:*.rlib=38;5;241:*.swp=38;5;244:*.swo=38;5;244:*.tmp=38;5;244: |
|
141
|
|
|
|
|
|
|
*.sassc=38;5;244:*.pid=38;5;248:*.state=38;5;248:*lockfile=38;5;248: |
|
142
|
|
|
|
|
|
|
*.err=38;5;160;1:*.error=38;5;160;1:*.stderr=38;5;160;1:*.dump=38;5;241: |
|
143
|
|
|
|
|
|
|
*.stackdump=38;5;241:*.zcompdump=38;5;241:*.zwc=38;5;241:*.pcap=38;5;29: |
|
144
|
|
|
|
|
|
|
*.cap=38;5;29:*.dmp=38;5;29:*.allow=38;5;112:*.deny=38;5;196: |
|
145
|
|
|
|
|
|
|
*.service=38;5;45:*@.service=38;5;45:*.socket=38;5;45:*.swap=38;5;45: |
|
146
|
|
|
|
|
|
|
*.device=38;5;45:*.mount=38;5;45:*.automount=38;5;45:*.target=38;5;45: |
|
147
|
|
|
|
|
|
|
*.path=38;5;45:*.timer=38;5;45:*.snapshot=38;5;45:*.application=38;5;116: |
|
148
|
|
|
|
|
|
|
*.cue=38;5;116:*.description=38;5;116:*.directory=38;5;116:*.m3u=38;5;116: |
|
149
|
|
|
|
|
|
|
*.m3u8=38;5;116:*.md5=38;5;116:*.properties=38;5;116:*.sfv=38;5;116: |
|
150
|
|
|
|
|
|
|
*.srt=38;5;116:*.theme=38;5;116:*.torrent=38;5;116:*.urlview=38;5;116: |
|
151
|
|
|
|
|
|
|
*.asc=38;5;192;3:*.enc=38;5;192;3:*.gpg=38;5;192;3:*.signature=38;5;192;3: |
|
152
|
|
|
|
|
|
|
*.sig=38;5;192;3:*.p12=38;5;192;3:*.pem=38;5;192;3:*.pgp=38;5;192;3: |
|
153
|
|
|
|
|
|
|
*.asc=38;5;192;3:*.enc=38;5;192;3:*.sig=38;5;192;3:*.signature=38;5;192;3: |
|
154
|
|
|
|
|
|
|
*.32x=38;5;213:*.cdi=38;5;213:*.fm2=38;5;213:*.rom=38;5;213:*.sav=38;5;213: |
|
155
|
|
|
|
|
|
|
*.st=38;5;213:*.a00=38;5;213:*.a52=38;5;213:*.A64=38;5;213:*.a64=38;5;213: |
|
156
|
|
|
|
|
|
|
*.a78=38;5;213:*.adf=38;5;213:*.atr=38;5;213:*.gb=38;5;213:*.gba=38;5;213: |
|
157
|
|
|
|
|
|
|
*.gbc=38;5;213:*.gel=38;5;213:*.gg=38;5;213:*.ggl=38;5;213:*.ipk=38;5;213: |
|
158
|
|
|
|
|
|
|
*.j64=38;5;213:*.nds=38;5;213:*.nes=38;5;213:*.sms=38;5;213:*.pot=38;5;7: |
|
159
|
|
|
|
|
|
|
*.pcb=38;5;7:*.mm=38;5;7:*.gbr=38;5;7:*.spl=38;5;7:*.scm=38;5;7: |
|
160
|
|
|
|
|
|
|
*.Rproj=38;5;11:*.sis=38;5;7:*.1p=38;5;7:*.3p=38;5;7:*.cnc=38;5;7: |
|
161
|
|
|
|
|
|
|
*.def=38;5;7:*.ex=38;5;7:*.example=38;5;7:*.feature=38;5;7:*.ger=38;5;7: |
|
162
|
|
|
|
|
|
|
*.map=38;5;7:*.mf=38;5;7:*.mfasl=38;5;7:*.mi=38;5;7:*.mtx=38;5;7:*.pc=38;5;7: |
|
163
|
|
|
|
|
|
|
*.pi=38;5;7:*.plt=38;5;7:*.pm=38;5;7:*.rb=38;5;7:*.rdf=38;5;7:*.rst=38;5;7: |
|
164
|
|
|
|
|
|
|
*.ru=38;5;7:*.sch=38;5;7:*.sty=38;5;7:*.sug=38;5;7:*.tdy=38;5;7:*.tfm=38;5;7: |
|
165
|
|
|
|
|
|
|
*.tfnt=38;5;7:*.tg=38;5;7:*.vcard=38;5;7:*.vcf=38;5;7:*.xln=38;5;7'; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$internal_ls_color =~ s/\n//g; |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $ls_colors_default = ' |
|
171
|
|
|
|
|
|
|
rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01: |
|
172
|
|
|
|
|
|
|
cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42: |
|
173
|
|
|
|
|
|
|
ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31: |
|
174
|
|
|
|
|
|
|
*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31: |
|
175
|
|
|
|
|
|
|
*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31: |
|
176
|
|
|
|
|
|
|
*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31: |
|
177
|
|
|
|
|
|
|
*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31: |
|
178
|
|
|
|
|
|
|
*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31: |
|
179
|
|
|
|
|
|
|
*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31: |
|
180
|
|
|
|
|
|
|
*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31: |
|
181
|
|
|
|
|
|
|
*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35 |
|
182
|
|
|
|
|
|
|
:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35: |
|
183
|
|
|
|
|
|
|
*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35: |
|
184
|
|
|
|
|
|
|
*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35: |
|
185
|
|
|
|
|
|
|
*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35: |
|
186
|
|
|
|
|
|
|
*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35: |
|
187
|
|
|
|
|
|
|
*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35: |
|
188
|
|
|
|
|
|
|
*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35: |
|
189
|
|
|
|
|
|
|
*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36: |
|
190
|
|
|
|
|
|
|
*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36: |
|
191
|
|
|
|
|
|
|
*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36'; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$ls_colors_default =~ s/\n|\s+//g; |
|
194
|
|
|
|
|
|
|
#> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# if LS_COLORS environment variable is unset, we use the default gnu |
|
197
|
|
|
|
|
|
|
# specification from dircolors. |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $extracted_ls_colors; |
|
200
|
|
|
|
|
|
|
my $LS_COLORS = defined($ENV{LS_COLORS}) ? $ENV{LS_COLORS} : $ls_colors_default; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# For situations like *.pl=38;5;196;1 (bold and red) |
|
203
|
|
|
|
|
|
|
my %attributes = ( |
|
204
|
|
|
|
|
|
|
1 => 'bold', |
|
205
|
|
|
|
|
|
|
2 => 'faint', |
|
206
|
|
|
|
|
|
|
3 => 'italic', |
|
207
|
|
|
|
|
|
|
4 => 'underline', |
|
208
|
|
|
|
|
|
|
5 => 'blink', |
|
209
|
|
|
|
|
|
|
6 => 'blink_ms', |
|
210
|
|
|
|
|
|
|
7 => 'reverse', |
|
211
|
|
|
|
|
|
|
); |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Alright, use our own LS_COLORS definition |
|
214
|
|
|
|
|
|
|
sub ls_color_internal { |
|
215
|
0
|
|
|
0
|
1
|
0
|
$LS_COLORS = $internal_ls_color; |
|
216
|
0
|
|
|
|
|
0
|
$extracted_ls_colors = parse_ls_colors($LS_COLORS); |
|
217
|
0
|
|
|
|
|
0
|
ls_color(@_); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub ls_color_custom { |
|
221
|
1
|
|
|
1
|
1
|
75
|
$LS_COLORS = shift; |
|
222
|
1
|
|
|
|
|
7
|
$extracted_ls_colors = parse_ls_colors($LS_COLORS); |
|
223
|
1
|
|
|
|
|
4
|
ls_color(@_); |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# Those are the default LS_COLORS mappings from GNU ls |
|
227
|
|
|
|
|
|
|
sub ls_color_default { |
|
228
|
1
|
|
|
1
|
1
|
851
|
$LS_COLORS= ' |
|
229
|
|
|
|
|
|
|
rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01: |
|
230
|
|
|
|
|
|
|
cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42: |
|
231
|
|
|
|
|
|
|
ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31: |
|
232
|
|
|
|
|
|
|
*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31: |
|
233
|
|
|
|
|
|
|
*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31: |
|
234
|
|
|
|
|
|
|
*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31: |
|
235
|
|
|
|
|
|
|
*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31: |
|
236
|
|
|
|
|
|
|
*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31: |
|
237
|
|
|
|
|
|
|
*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31: |
|
238
|
|
|
|
|
|
|
*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31: |
|
239
|
|
|
|
|
|
|
*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35 |
|
240
|
|
|
|
|
|
|
:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35: |
|
241
|
|
|
|
|
|
|
*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35: |
|
242
|
|
|
|
|
|
|
*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35: |
|
243
|
|
|
|
|
|
|
*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35: |
|
244
|
|
|
|
|
|
|
*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35: |
|
245
|
|
|
|
|
|
|
*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35: |
|
246
|
|
|
|
|
|
|
*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35: |
|
247
|
|
|
|
|
|
|
*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36: |
|
248
|
|
|
|
|
|
|
*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36: |
|
249
|
|
|
|
|
|
|
*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36'; |
|
250
|
|
|
|
|
|
|
|
|
251
|
1
|
|
|
|
|
146
|
$LS_COLORS =~ s/\n|\s+//g; |
|
252
|
|
|
|
|
|
|
|
|
253
|
1
|
|
|
|
|
3
|
$extracted_ls_colors = parse_ls_colors($LS_COLORS); |
|
254
|
1
|
|
|
|
|
3
|
ls_color(@_); |
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# none of the ls_color_* variations are called, so we use the the |
|
259
|
|
|
|
|
|
|
# LS_COLORS defined in the environment variable. |
|
260
|
|
|
|
|
|
|
$extracted_ls_colors = parse_ls_colors($LS_COLORS); |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub ls_color { |
|
264
|
2
|
|
|
2
|
1
|
4
|
my @files; |
|
265
|
|
|
|
|
|
|
|
|
266
|
2
|
50
|
|
|
|
6
|
if(ref($_[0]) eq 'ARRAY') { |
|
267
|
0
|
|
|
|
|
0
|
push(@files, @{$_[0]}); |
|
|
0
|
|
|
|
|
0
|
|
|
268
|
0
|
|
|
|
|
0
|
shift @_; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
else { |
|
271
|
2
|
|
|
|
|
5
|
push(@files, @_); |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
|
275
|
2
|
|
|
|
|
11
|
for my $file(@files) { |
|
276
|
2
|
|
|
|
|
5
|
chomp $file; |
|
277
|
2
|
50
|
|
|
|
7
|
next if $file =~ m/^\s+$/; |
|
278
|
|
|
|
|
|
|
# it's important to keep the dot if there is one. If you remove the dot, |
|
279
|
|
|
|
|
|
|
# directories named bin/ can be miscolored given a key like |
|
280
|
|
|
|
|
|
|
# *.bin=38;5;220 |
|
281
|
|
|
|
|
|
|
|
|
282
|
2
|
|
|
|
|
8
|
my($ext) = $file =~ m/.*([.]+.+)$/; |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# since we need to stat files, we need a real filename that's not padded with |
|
285
|
|
|
|
|
|
|
# whitespace. |
|
286
|
|
|
|
|
|
|
|
|
287
|
2
|
|
|
|
|
3
|
my $real_file; |
|
288
|
2
|
50
|
|
|
|
5
|
if($file =~ m/^\s+(.+)/) { |
|
289
|
0
|
|
|
|
|
0
|
$real_file = $1; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
else { |
|
292
|
2
|
|
|
|
|
4
|
$real_file = $file; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# no extension found. let's check file attributes. this will only |
|
297
|
|
|
|
|
|
|
# work if called with absolute paths or from ./ since we can't stat files that |
|
298
|
|
|
|
|
|
|
# we can't access. |
|
299
|
|
|
|
|
|
|
# https://github.com/trapd00r/File-LsColor/issues/1 |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
# ./recup_dir.5/ |
|
302
|
|
|
|
|
|
|
# Invalid \0 character in pathname for ftdir: \0ls++.conf at LsColor.pm |
|
303
|
|
|
|
|
|
|
|
|
304
|
2
|
50
|
|
|
|
5
|
if($real_file !~ m/\0/) { |
|
305
|
2
|
50
|
|
|
|
65
|
-d $real_file and $ext = 'di'; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
2
|
50
|
33
|
|
|
8
|
if( not defined($ext) and $NO_STAT == 0) { |
|
309
|
0
|
0
|
|
|
|
0
|
-l $real_file and $ext = 'ln'; # symlink |
|
310
|
0
|
0
|
|
|
|
0
|
-x $real_file and $ext = 'ex'; # executable |
|
311
|
0
|
0
|
|
|
|
0
|
-d $real_file and $ext = 'di'; # beware, dirs have +x |
|
312
|
0
|
0
|
|
|
|
0
|
-S $real_file and $ext = 'so'; # socket |
|
313
|
0
|
0
|
|
|
|
0
|
-p $real_file and $ext = 'pi'; # fifo, pipe |
|
314
|
0
|
0
|
|
|
|
0
|
-b $real_file and $ext = 'bd'; # block device |
|
315
|
0
|
0
|
|
|
|
0
|
-c $real_file and $ext = 'cd'; # character special file |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
# special case for directories that we can't stat, but we can still safely |
|
318
|
|
|
|
|
|
|
# assume that they are in fact dirs. |
|
319
|
|
|
|
|
|
|
|
|
320
|
0
|
0
|
|
|
|
0
|
$real_file =~ m{/$} and $ext = 'di'; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
|
|
323
|
2
|
50
|
|
|
|
7
|
if(!defined($ext)) { |
|
324
|
|
|
|
|
|
|
# Since these: |
|
325
|
|
|
|
|
|
|
# Makefile |
|
326
|
|
|
|
|
|
|
# README |
|
327
|
|
|
|
|
|
|
# *Makefile.PL |
|
328
|
|
|
|
|
|
|
# are all perfectly valid keys |
|
329
|
0
|
|
|
|
|
0
|
$ext = $real_file; |
|
330
|
|
|
|
|
|
|
} |
|
331
|
|
|
|
|
|
|
|
|
332
|
2
|
50
|
0
|
|
|
8
|
if(exists($extracted_ls_colors->{$real_file})) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
0
|
$file = fg($extracted_ls_colors->{$real_file}, $file); |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
elsif(exists($extracted_ls_colors->{$ext})) { |
|
336
|
2
|
|
|
|
|
9
|
$file = fg($extracted_ls_colors->{$ext}, $file); |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# We haven't found a valid extension -> color mapping yet, but if |
|
340
|
|
|
|
|
|
|
# IGNORE_CASE is true, check if the lowercase version of the capitalized |
|
341
|
|
|
|
|
|
|
# extension does in fact exist. |
|
342
|
|
|
|
|
|
|
# Just make sure to use the non-lc version while returning. |
|
343
|
|
|
|
|
|
|
# https://github.com/trapd00r/File-LsColor/issues/9 |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
elsif($IGNORE_CASE && $extracted_ls_colors->{lc($ext)}) { |
|
346
|
0
|
|
|
|
|
0
|
$file = fg($extracted_ls_colors->{lc($ext)}, $file); |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
else { |
|
349
|
|
|
|
|
|
|
# $file = fg(32, $file); |
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
} |
|
352
|
2
|
100
|
|
|
|
112
|
return wantarray() ? @files : join('', @files); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub get_ls_colors { |
|
357
|
6
|
|
|
6
|
1
|
25
|
return parse_ls_colors() |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub parse_ls_colors { |
|
362
|
5
|
50
|
|
5
|
1
|
15
|
if(@_) { |
|
363
|
5
|
|
|
|
|
9
|
$LS_COLORS = shift @_; |
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
# if( (!defined($LS_COLORS)) or ($LS_COLORS eq '') ) { |
|
367
|
|
|
|
|
|
|
# croak("LS_COLORS variable not set! Nothing to do...\n"); |
|
368
|
|
|
|
|
|
|
# } |
|
369
|
|
|
|
|
|
|
# *.flac=38;5;196 |
|
370
|
5
|
|
|
|
|
57
|
my @entities = split(/:/, $LS_COLORS); |
|
371
|
|
|
|
|
|
|
|
|
372
|
5
|
|
|
|
|
9
|
my %ft; |
|
373
|
5
|
|
|
|
|
9
|
for my $ent(@entities) { |
|
374
|
|
|
|
|
|
|
# account for: |
|
375
|
|
|
|
|
|
|
# *.flac - but keep the dot in the extension |
|
376
|
|
|
|
|
|
|
# *MANIFEST |
|
377
|
390
|
|
|
|
|
1013
|
my ($filetype, $attributes) = $ent =~ m/[*]*(.?\S+)=([\d;]+|target)/; |
|
378
|
|
|
|
|
|
|
# print "extracted ft: $filetype | attr: $attributes\n"; |
|
379
|
390
|
|
|
|
|
848
|
$ft{$filetype} = $attributes; |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
# if symlink value is target, we use the target key's value |
|
383
|
|
|
|
|
|
|
# if($ft{ln} eq 'target') { |
|
384
|
|
|
|
|
|
|
# $ft{ln} = $ft{target}; |
|
385
|
|
|
|
|
|
|
# } |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# account for: |
|
388
|
|
|
|
|
|
|
# *.flac |
|
389
|
|
|
|
|
|
|
# *MANIFEST |
|
390
|
5
|
|
|
|
|
81
|
return \%ft; |
|
391
|
|
|
|
|
|
|
} |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub can_ls_color { |
|
394
|
6
|
|
|
6
|
1
|
139
|
my $ft = shift; |
|
395
|
6
|
|
|
|
|
9
|
my $table = get_ls_colors(); |
|
396
|
|
|
|
|
|
|
|
|
397
|
6
|
|
|
|
|
59
|
$ft =~ s/^\s+//; |
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# if called with an extension that exists, return it. |
|
401
|
6
|
100
|
|
|
|
25
|
return $table->{$ft} if $table->{$ft}; |
|
402
|
3
|
100
|
|
|
|
14
|
return $table->{".$ft"} if $table->{".$ft"}; |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
# else, check if called with a filename.ext |
|
405
|
|
|
|
|
|
|
# return undef if all else fails |
|
406
|
|
|
|
|
|
|
{ |
|
407
|
2
|
|
|
2
|
|
15
|
no warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
195
|
|
|
|
2
|
|
|
|
|
4
|
|
|
408
|
2
|
|
|
|
|
8
|
my($ext) = $ft =~ m/^.*([.].+)$/; |
|
409
|
2
|
100
|
|
|
|
13
|
return $table->{$ext} ? $table->{$ext} : undef; |
|
410
|
|
|
|
|
|
|
} |
|
411
|
|
|
|
|
|
|
} |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
1; |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
__END__ |