Add today script
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 13 Mar 2019 10:32:55 +0000 (06:32 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 13 Mar 2019 10:32:55 +0000 (06:32 -0400)
.profile
bin/today [new file with mode: 0755]

index a7399c2..e94e141 100644 (file)
--- a/.profile
+++ b/.profile
@@ -1,3 +1,5 @@
+. $HOME/lib/login_variables.private.sh  # Personal data variables
+
 for file in $HOME/lib/login_*.sh
 do
     . $file
diff --git a/bin/today b/bin/today
new file mode 100755 (executable)
index 0000000..0c7192a
--- /dev/null
+++ b/bin/today
@@ -0,0 +1,65 @@
+#! /bin/sh
+
+set -e
+
+repeat() {
+    x="$1"
+    n="$2"
+    awk -v x="$x" -v n="$n" 'BEGIN {for (i=1; i<=n; i++) {printf x}}'
+}
+
+bar=$(repeat '-' '80')
+ts_fmt='+%A, %Y %B %d, %H:%M:%S'
+ts_lang='el_GR.UTF-8'
+timestamp_local=$(LANG="$ts_lang"                 date "$ts_fmt")
+timestamp_west=$( LANG="$ts_lang" TZ='US/Pacific' date "$ts_fmt")
+timestamp_pl=$(   LANG="$ts_lang" TZ='Poland'     date "$ts_fmt")
+timestamp_nz=$(   LANG="$ts_lang" TZ='NZ'         date "$ts_fmt")
+
+ip_addresses=$(
+    ip addr \
+    | awk '
+        /^[0-9]+:/ {
+            interface = $2
+            sub(":$", "", interface)
+            interfaces[++interface_count] = interface
+        }
+
+        /^ +inet +/ {
+            addr = $2
+            sub("/[0-9]+$", "", addr)
+            addrs[interface] = addr
+        }
+
+        END {
+            for (i=1; i<=interface_count; i++) {
+                interface = interfaces[i]
+                print interface, addrs[interface]
+            }
+        }' \
+    | column -t
+)
+
+weather=$(
+    curl "http://wttr.in/${ZIP_CODE}?1" 2> /dev/null \
+    || \
+    echo "Weather update failed" \
+)
+
+clear
+#LANG="$ts_lang" ncal -M $(date +%Y)
+LANG="$ts_lang" ncal -M
+echo "$bar"
+(
+    echo 'LOCAL'       ',' "$timestamp_local"
+    echo 'Pacific'     ',' "$timestamp_west"
+    echo 'Poland'      ',' "$timestamp_pl"
+    echo 'New Zealand' ',' "$timestamp_nz"
+) \
+| column -ts,
+echo "$bar"
+echo "$ip_addresses"
+echo "$bar"
+echo ''
+echo "$weather"
+echo ''
This page took 0.019651 seconds and 4 git commands to generate.