commit 9b32510c019a643ed644a566ad0ab82e3fbca555
parent 84c41ff395103f4cc2100469d4ec175436eb1a6c
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Mon, 22 Jun 2020 15:15:16 +0200

Add st config

Diffstat:
M.config/Xresources | 20++++++++++++++++++++
A.local/bin/xurls | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/.config/Xresources b/.config/Xresources @@ -30,3 +30,23 @@ dwm.normbordercolor: border dwm.selbgcolor: selbg dwm.selfgcolor: selfg dwm.selbordercolor: selborder + +st.color0: black +st.color8: black +st.color1: red +st.color9: red +st.color2: green +st.color10: green +st.color3: yellow +st.color11: yellow +st.color4: blue +st.color12: blue +st.color5: purple +st.color13: purple +st.color6: cyan +st.color14: cyan +st.color7: white +st.color15: white + +st.background: white +st.foreground: black diff --git a/.local/bin/xurls b/.local/bin/xurls @@ -0,0 +1,117 @@ +#!/usr/bin/env perl + +use warnings; + +$hostchars = '[a-z0-9-._+]'; +$pathchars = '[a-z0-9-._+#=?&:;%/!,~]'; + +sub scan($$$) +{ + my ($file, $lineno, $line) = @_; + + chomp $line; + + while($line =~ s! + ([a-z]+://)? + +# http:// + + $hostchars+\.[a-z]+ + +# www.tim.google.com - the [a-z].com is the main anchor for the whole regex - incase http:// is omitted +# note no trailing slash + + ($pathchars+/\?)* + +# check for the index.php? part + + ($pathchars+|\($pathchars+\))* + +# check for pathchars, or a set of nested parens + !!xoi){ # allow space + comments, compile once, strcasecmp + + my($p,$m,$e) = ($`,$&,$'); + + $e = '.' . $e if $m =~ s/\.$//; + + if($opt{fname} && $file){ + print "$col{red}$file$col{none}:"; + } + + if($opt{lineno}){ + print "$col{green}$lineno$col{none}: "; + }elsif($opt{fname} && $file){ + print ' '; + } + + if($opt{hl}){ + print "$p$col{brown}$m$col{none}$e\n"; + }else{ + print "$m\n"; + } + } +} + +sub usage(){ + $printme =<<"!"; +Usage: $0 -[Chn] [FILES...] + -h: highlight + -c: force colour on (for pipes) + -C: colour off (only makes sense with -h) + -n: show line number +! + print STDERR $printme; + exit 1; +} + + +%opt = ( + colour => 1, + lineno => 0, + fname => 0, + hl => 0 +); +%col = ( + brown => "\e[0;31m", # hl + red => "\e[0;35m", # fname + green => "\e[0;32m", # lineno + none => "\e[0;0m" +); + +for $arg (@ARGV){ + if($arg eq '-h'){ + $opt{hl} = 1; + }elsif($arg eq '-n'){ + $opt{lineno} = 1; + }elsif($arg eq '-C'){ + $opt{colour} = 0; + }elsif($arg eq '-c'){ + usage() if $opt{colour} == 0; + $opt{colour} = 2; # force on + }elsif($arg eq '--help'){ + usage(); + }else{ + push @files, $arg; + } +} + +usage() if $opt{hl} && !$opt{colour}; + +$opt{fname} = 1 if $#files > 0 || $opt{lineno}; +if(!$opt{colour} || ($opt{colour} == 1 && !-t STDOUT)){ + $col{$_} = '' for keys %col; +} + +$| = 1; + +if(@files){ + for my $f (@files){ + my $n = 1; + open F, '<', $f or warn "$f: $!\n"; + scan($f, $n++, $_) for <F>; + close F; + } +}else{ + scan(undef, $., $_) while <STDIN>; +} +