dot

packages and services management
Log | Files | Refs | README

commit cdd0c50e5128fdb0eee9b3d61e0d54eaae7d4955
parent fc6d9ad9a8e5eed17088bb6dcf25c5f43640353e
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 20 May 2017 16:31:36 +0200

ii-filter

Diffstat:
M.profile | 7+++++--
Dbin/ii-filter | 61-------------------------------------------------------------
Abin/ii-filter-1 | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbin/ii-filter-3 | 18+++++++++++++++---
Mbin/manpager | 2+-
5 files changed, 82 insertions(+), 67 deletions(-)

diff --git a/.profile b/.profile @@ -98,21 +98,24 @@ case "$(tty)" in ( /dev/tty* ) esac -# aliases - # core + alias l='ls -lp' alias la='ls -lpA' alias cl='printf "\033[H\033[2J"' + # iomenu + alias j='fg "%`jobs | iomenu | sed -r "s/.([0-9]*).*/\1/"`"' alias f='find . ! -path "*/.git/*" -type f | iomenu -p file' alias d='find . ! -path "*/.git/*" -type d | iomenu -p directory' alias c='cd "$(find "$HOME" -type d | sort | iomenu -p cd)"' alias p='p=`io-ps`' + # utilities + alias myip='curl icanhazip.com' alias ix='curl -F "f:1=<-" ix.io' alias w1r3='curl -F upload=@- https://w1r3.net' diff --git a/bin/ii-filter b/bin/ii-filter @@ -1,61 +0,0 @@ -busybox awk ' - -BEGIN { - NICK_COL = 14; - TEXT_COL = 80 - NICK_COL - length(" "); -} - -/^$/ { - next; -} - -/==> .* <==/ { - sub("/out <==", ""); - sub("==> ", ""); - - print("\n" $0); - - next; -} - -{ - sub(/[0-9]*-[0-9]*-[0-9]* /, ""); - - date = $0; - sub(/ .*/, "", date); - sub(/^[^ ]* /, "", $0 ); - - if (match($0, /^[-=<#*@+]/)) { - nick = $0; - sub(/ .*/, "", nick); - sub(/^[^ ]* /, "", $0 ); - sub(/</, "", nick); - sub(/>/, "", nick); - } else { - nick = "-!-"; - } - - if (nick != lastnick) - printf("%-" NICK_COL "s│\n", date); - - printf("%" NICK_COL "s│ ", - (nick != lastnick && nick != "-!-") ? nick : ""); - - for (first = 1; length($0) >= TEXT_COL; first = 0) { - line = substr($0, 1, TEXT_COL); - sub(/ [^ ]*$/, "", line); - $0 = substr($0, length(line) + 1); - - if (!first) - printf("%" NICK_COL "s│ ", ""); - - print(line); - } - - if (!first) - printf("%" NICK_COL "s│ ", ""); - - print($0); - - lastnick = nick; -}' "$@" diff --git a/bin/ii-filter-1 b/bin/ii-filter-1 @@ -0,0 +1,61 @@ +busybox awk ' + +BEGIN { + NICK_COL = 14; + TEXT_COL = 80 - NICK_COL - length(" "); +} + +/^$/ { + next; +} + +/==> .* <==/ { + sub("/out <==", ""); + sub("==> ", ""); + + print("\n" $0); + + next; +} + +{ + sub(/[0-9]*-[0-9]*-[0-9]* /, ""); + + date = $0; + sub(/ .*/, "", date); + sub(/^[^ ]* /, "", $0 ); + + if (match($0, /^[-=<#*@+]/)) { + nick = $0; + sub(/ .*/, "", nick); + sub(/^[^ ]* /, "", $0 ); + sub(/</, "", nick); + sub(/>/, "", nick); + } else { + nick = "-!-"; + } + + if (nick != lastnick) + printf("%-" NICK_COL "s|\n", date); + + printf("%" NICK_COL "s| ", + (nick != lastnick && nick != "-!-") ? nick : ""); + + for (first = 1; length($0) >= TEXT_COL; first = 0) { + line = substr($0, 1, TEXT_COL); + sub(/ [^ ]*$/, "", line); + $0 = substr($0, length(line) + 1); + + if (!first) + printf("%" NICK_COL "s| ", ""); + + print(line); + } + + if (!first) + printf("%" NICK_COL "s| ", ""); + + print($0); + + lastnick = nick; +}' "$@" diff --git a/bin/ii-filter-3 b/bin/ii-filter-3 @@ -7,12 +7,24 @@ awk ' } date != last { - printf("----------------( %s )----------------", date); + printf("%s ---------------------------------------------\n", date); } { - printf("%s %14s ", $2, $3); - sub("[^ ]* *[^ ]* *[^ ]* *", ""); + if ($3 ~ "<.*>") { + sub("<", "", $3); + sub(">", "", $3); + printf("%s %10s ", $2, $3); + sub("[^ ]* *[^ ]* *[^ ]*", ""); + } else { + printf("%s %10s ", $2, ""); + sub("[^ ]* *[^ ]*", ""); + } + + while (match("^.{50}")) { + line = $0; + substr + print } ' diff --git a/bin/manpager b/bin/manpager @@ -1,4 +1,4 @@ tmp=`mktemp` -sed 's/.//g' > "$tmp" +[ $# -gt 0 ] && sed 's/.//g' "$1" > "$tmp" exec $EDITOR -R "$tmp" < /dev/tty