added ip.borked.sh, works only in alpine linux (and others that have -o option for `column`)
shows you IP addresses, parsed from `ip a`, and displayed in either a unicode, or ascii art table
This commit is contained in:
parent
b4d495aaac
commit
8ca76bb751
|
@ -0,0 +1,106 @@
|
|||
#!/bin/sh
|
||||
alias sed="busybox sed"
|
||||
case "$1" in
|
||||
""|"-u"|"--utf")
|
||||
#top line char
|
||||
tl='━'
|
||||
#bottom line char
|
||||
bl='═' #$tl
|
||||
#left line char
|
||||
ll='│'
|
||||
#right line char
|
||||
rl=$ll
|
||||
|
||||
#header line left
|
||||
hl='┃' #$ll
|
||||
#header line right
|
||||
hr=$hl #$rl
|
||||
|
||||
#corner top-left
|
||||
ctl='┏'
|
||||
#corner top-right
|
||||
ctr='┓'
|
||||
#corner bottom-left
|
||||
cbl='╘'
|
||||
#corner bottom-right
|
||||
cbr='╛'
|
||||
|
||||
#separator line horizontal char
|
||||
slh='─'
|
||||
#separator left end
|
||||
sle='┞─'
|
||||
#separator right end
|
||||
sre='─┦'
|
||||
;;
|
||||
#----------------------
|
||||
"-a"|"--ascii")
|
||||
#top line char
|
||||
tl='~'
|
||||
#bottom line char
|
||||
bl='=' #$tl
|
||||
#left line char
|
||||
ll='!'
|
||||
#right line char
|
||||
rl=$ll
|
||||
|
||||
#header line left
|
||||
hl='|' #$ll
|
||||
#header line right
|
||||
hr=$hl #$rl
|
||||
|
||||
#corner top-left
|
||||
ctl='/'
|
||||
#ctl='+'
|
||||
#corner top-right
|
||||
ctr='\\'
|
||||
#ctr='+'
|
||||
#corner bottom-left
|
||||
cbl=$ctr
|
||||
#corner bottom-right
|
||||
cbr=$ctl
|
||||
|
||||
#separator line horizontal char
|
||||
slh='-'
|
||||
#separator left end
|
||||
sle='|-'
|
||||
#separator right end
|
||||
sre='-|'
|
||||
;;
|
||||
"-r"|"--raw")true;;
|
||||
*)
|
||||
echo "syntax: $0 [-u|--utf|-a|--ascii|-r|--raw]"
|
||||
echo "defaults to unicode mode"
|
||||
echo "raw mode was an unintentional side effect"
|
||||
exit;;
|
||||
esac
|
||||
thing=$(
|
||||
ip a|
|
||||
grep -vE "^([ ]* inet(6|)?) ((\:\:1)|fe80\:\:|(127\.0\.0\.1))"|
|
||||
grep inet|
|
||||
tr -s " "|
|
||||
cut -d" " -f3|
|
||||
sed -e "s|/| /|" -e "1s/^/ADDRESSES MASK\n/");
|
||||
len1=$(
|
||||
echo $thing|
|
||||
sed "s/\s/&\n/g"|
|
||||
sed "Ns/\n//"|
|
||||
cut -d" " -f1|
|
||||
wc -L);
|
||||
len2=$(
|
||||
echo $thing|
|
||||
sed "s/\s/&_\n/g"|
|
||||
sed "Ns/\n//"|
|
||||
cut -d" " -f2|
|
||||
wc -L);
|
||||
ip a|
|
||||
grep -vE "^([ ]* inet(6|)?) ((\:\:1)|fe80\:\:|(127\.0\.0\.1))"|
|
||||
grep inet|tr -s " "|
|
||||
cut -d" " -f3|
|
||||
sed -e "s|/|\t /|g" -e "1s/^/ADDRESSES\t MASK\n$(printf %${len1}s|sed "s/./$slh/g")\t$(printf %${len2}s|sed "s/./$slh/g")\n/"|
|
||||
sed -e "s/^/${ll} /" -e "s/$/\t ${rl}/" |
|
||||
sed -e "1s/^$ll /$hl /" -e "1s/ $rl$/ $hr/" \
|
||||
-e "2s/^$ll /$sle/" -e "2s/ $rl$/$sre/" |
|
||||
column -t -s" " -o ""|
|
||||
sed "1s\`^\`${ctl}${tl}${tl}$(printf "%${len1:-"1"}s"|sed "s/./$tl/g")$(printf "%${len2:-"1"}s"|sed "s/./$tl/g")${ctr}\n\`"|sed "$ s\`$\`\n${cbl}${bl}${bl}$(printf "%${len1:-"1"}s"|
|
||||
sed "s/./$bl/g")$(printf "%${len2:-"1"}s"|
|
||||
sed "s/./$bl/g")${cbr}\`"
|
Loading…
Reference in New Issue