X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Flib%2Flogin_functions.sh;h=0ff4e86204e0f7e436f5dfae168f717b21620d9f;hb=a2755d82f7beae4d82f148b58f6273e3c83983fc;hp=75cfd1d8ac7aa0f75c41d6b216d775e8f34ca25c;hpb=3f43e4e005ef160f0794467a77284ace3049d5af;p=khome.git diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 75cfd1d..0ff4e86 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -1,5 +1,33 @@ # +## p : string -> unit +p() { + awk \ + -v _s="$1" \ + ' + BEGIN {_s = tolower(_s)} + + /^[a-zA-Z]/ && tolower($1) ~ _s && NF >= 2 { + s = $1 + p = $NF + if (NF == 2) { + e = "" + u = "" + } else if (NF == 3) { + e = $2 + u = "" + } else { + e = $2 + u = $3 + } # TODO What would NF > 4 mean? + printf("s:\"%s\", e:\"%s\", u:\"%s\"\n", s, e, u) > "/dev/stderr" + printf "%s", p # XXX Intentionally avoiding newline in the result. + } + ' \ + ~/._p/p \ + | xsel -i -b -t 30000 +} + ## web search ## ws : string -> unit ws() {