home
/
code
/
khome.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3f43e4e
)
Add p function
author
Siraaj Khandkar
<siraaj@khandkar.net>
Wed, 2 Feb 2022 14:02:13 +0000
(09:02 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Wed, 2 Feb 2022 14:31:38 +0000
(09:31 -0500)
home/lib/login_functions.sh
patch
|
blob
|
blame
|
history
diff --git
a/home/lib/login_functions.sh
b/home/lib/login_functions.sh
index
75cfd1d
..
0ff4e86
100644
(file)
--- 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() {
## web search
## ws : string -> unit
ws() {
This page took
0.032533 seconds
and
4
git commands to generate.