1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

update nth to select (#147)

This commit is contained in:
Michael Angerman 2022-02-15 17:01:42 -08:00 committed by GitHub
parent 166a9b5eac
commit c326716e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View file

@ -12,12 +12,12 @@ def locations [] {
}
def get_my_location [index: int] {
let loc_json = (fetch (locations | nth $index).0.location)
let city_column = (locations | nth $index).0.city_column
let state_column = (locations | nth $index).0.state_column
let country_column = (locations | nth $index).0.country_column
let lat_column = (locations | nth $index).0.lat_column
let lon_column = (locations | nth $index).0.lon_column
let loc_json = (fetch (locations | select $index).0.location)
let city_column = (locations | select $index).0.city_column
let state_column = (locations | select $index).0.state_column
let country_column = (locations | select $index).0.country_column
let lat_column = (locations | select $index).0.lat_column
let lon_column = (locations | select $index).0.lon_column
# echo $loc_json
if ($city_column | str length) > 1 {
@ -74,7 +74,7 @@ def get_weather_by_ip [locIdx: int, units: string] {
{
id: ($day.weather.0.id)
dt: ($day.dt | into string | into datetime -z local | date format '%Y-%m-%d')
high: ($day.temp.max)
high: ($day.temp.max)
low: ($day.temp.min)
}
})
@ -112,7 +112,7 @@ def get_weather_by_ip [locIdx: int, units: string] {
{
id: ($day.weather.0.id)
dt: ($day.dt | into string | into datetime -z local | date format '%Y-%m-%d')
high: ($day.temp.max)
high: ($day.temp.max)
low: ($day.temp.min)
}
})
@ -301,4 +301,4 @@ def get_emoji_by_id [id] {
# This uses location 2 and Celcius degrees. f = Fahrenheit, c = Celcius
# Since I live in the USA I have not tested outside the country.
# We'll take PRs for things that are broke or augmentations.
# We'll take PRs for things that are broke or augmentations.

View file

@ -70,10 +70,11 @@ def timed_weather_run [
$weather_table | update last_run_time {(date now | date format '%Y-%m-%d %H:%M:%S %z')} | save $weather_runtime_file
}
} else {
echo "Your command did not run because you are not on Windows..."
# ToDo: refactor the info in the Windows section into another def. The only real difference
# is where the temp file will be located. Mac & Linux probably should be in /tmp I guess.
# everything else is linux or mac
}
}
timed_weather_run --command "get_weather" --interval 1min
timed_weather_run --command "get_weather" --interval 1min