Add timestamp scripts
[khome.git] / bin / today
CommitLineData
4af9eedb
SK
1#! /bin/sh
2
3set -e
4
5repeat() {
6 x="$1"
7 n="$2"
8 awk -v x="$x" -v n="$n" 'BEGIN {for (i=1; i<=n; i++) {printf x}}'
9}
10
11bar=$(repeat '-' '80')
12ts_fmt='+%A, %Y %B %d, %H:%M:%S'
13ts_lang='el_GR.UTF-8'
14timestamp_local=$(LANG="$ts_lang" date "$ts_fmt")
15timestamp_west=$( LANG="$ts_lang" TZ='US/Pacific' date "$ts_fmt")
16timestamp_pl=$( LANG="$ts_lang" TZ='Poland' date "$ts_fmt")
17timestamp_nz=$( LANG="$ts_lang" TZ='NZ' date "$ts_fmt")
18
19ip_addresses=$(
20 ip addr \
21 | awk '
22 /^[0-9]+:/ {
23 interface = $2
24 sub(":$", "", interface)
25 interfaces[++interface_count] = interface
26 }
27
28 /^ +inet +/ {
29 addr = $2
30 sub("/[0-9]+$", "", addr)
31 addrs[interface] = addr
32 }
33
34 END {
35 for (i=1; i<=interface_count; i++) {
36 interface = interfaces[i]
37 print interface, addrs[interface]
38 }
39 }' \
40 | column -t
41)
42
43weather=$(
44 curl "http://wttr.in/${ZIP_CODE}?1" 2> /dev/null \
45 || \
46 echo "Weather update failed" \
47)
48
49clear
50#LANG="$ts_lang" ncal -M $(date +%Y)
51LANG="$ts_lang" ncal -M
52echo "$bar"
53(
54 echo 'LOCAL' ',' "$timestamp_local"
55 echo 'Pacific' ',' "$timestamp_west"
56 echo 'Poland' ',' "$timestamp_pl"
57 echo 'New Zealand' ',' "$timestamp_nz"
58) \
59| column -ts,
60echo "$bar"
61echo "$ip_addresses"
62echo "$bar"
63echo ''
64echo "$weather"
65echo ''
This page took 0.032639 seconds and 4 git commands to generate.