-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwttr
More file actions
executable file
·58 lines (53 loc) · 1.54 KB
/
wttr
File metadata and controls
executable file
·58 lines (53 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: wttr
# Created: Tuesday, 2020/02/18 - 20:44:58
# Author.: @fbnmtz, fgm (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:41:22
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.3.64
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# > see whether of a city form terminal
# ############################################################################
# HISTORY:
#
# shellcheck disable=SC1090
source "$xSHELL_INIT"
xrequirements cut tr curl sed
xsetHome
WEATHER_URL=wttr.in
FILENAME=""
getFileName(){
local location=$1
FILENAME=$location.txt
echo "$FILENAME"
}
getWTTR(){
local location=$1
local filename=$2
if [ ! -f "$filename" ]; then
curl -s "$WEATHER_URL/$location" > "$filename" && sed -i '$ d' "$filename"
fi
}
if [ -n "$1" ]; then
city=$(echo "$@" | tr -s ' ' '-')
FILENAME="$city.txt"
if [ ! -f "$APP_HOME/$FILENAME" ]; then
getWTTR "$city" "$APP_HOME/$FILENAME"
fi
cat "$APP_HOME"/"$FILENAME"
else
for city in ${APP_HOME}/*; do
FILENAME="${city}"
if [ ! -f "$FILENAME" ]; then
getWTTR "$city" "$FILENAME"
fi
cat "$FILENAME" || exit
read -r
done
fi