Add p function
[khome.git] / home / lib / login_functions.sh
index 0fc9ef1..0ff4e86 100644 (file)
@@ -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() {
@@ -384,15 +412,6 @@ note() {
     vim -c 'set spell' "$DIR_NOTES/$(date +'%Y_%m_%d--%H_%M_%S%z')--$1.md"
 }
 
-weather() {
-    local _weather_location
-    case "$1" in
-        '') _weather_location="$WEATHER_LOCATION";;
-         *) _weather_location="$1"
-    esac
-    curl "http://wttr.in/$_weather_location?format=v2"
-}
-
 _bt_devs_infos() {
     # grep's defintion of a line does not include \r, wile awk's does and
     # which bluetoothctl outputs
This page took 0.030963 seconds and 4 git commands to generate.