]> git.nbdom.net Git - nb.git/commitdiff
html2txt
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jan 2017 11:46:59 +0000 (11:46 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jan 2017 11:46:59 +0000 (11:46 +0000)
etc/profile.d/net.sh

index d4110be9b44e280dca5ca6bc89e6b3d46b4f58a2..5df372d955b7f6308ed4cf9ed7685fd3ea355406 100644 (file)
@@ -11,8 +11,7 @@ resolve() {
   ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge'
 }
 
-mask2cdr ()
-{
+mask2cdr() {
    # Assumes there's no "255." after a non-255 byte in the mask
    local x=${1##*255.}
    set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
@@ -21,10 +20,13 @@ mask2cdr ()
 }
 
 
-cdr2mask ()
-{
+cdr2mask() {
    # Number of args to shift, 255..255, first non-255 byte, zeroes
    set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
    [ $1 -gt 1 ] && shift $1 || shift
    echo ${1-0}.${2-0}.${3-0}.${4-0}
 }
+
+html2txt() {
+  lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999 -dump $@
+}