openvolga/when_my_bus.sh
2024-12-31 02:27:30 +03:00

11 lines
558 B
Bash
Executable file

#!/bin/bash
selected_station=$(cat stations.json | jq -r '.[] | "\(.station_id | tostring) \(.name) - \(.address)"' | fzf --bind 'enter:become(echo {1})')
fetch_buses_from_station() {
echo "Nearest buses from station $1:"
curl -s -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:127.0) Gecko/20100101 Firefox/127.0' --compressed "https://api.merlin.tvercard.ru/api/client/v1/stations/$1/schedules/nearest?nearest_vehicle_amount=10" | jq .
}
export -f fetch_buses_from_station
watch --interval 5 -x bash -c "fetch_buses_from_station $selected_station"