Created
July 18, 2018 18:51
-
-
Save andycochrane/9ea5a024a539803f4f7413d8ea2db457 to your computer and use it in GitHub Desktop.
Open National Rail train times in your default browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# I would recommend saving this function in your .bash_profile file or wherever you keep your custom functions. | |
# Alternatively you could save this in a shell script file. | |
# The function takes up to 4 arguments. FROM, TO, TIME & DATE. Change the defaults below to whatever suits you. | |
# With no arguments passed this will get you the next trains between the default (Leeds and Kings Cross) stations. | |
# This works in a bash shell on Mac OSX. If you are not a Mac user, replace the "open" command with whichever one works on your platform. | |
# To find the station codes for your station run this: | |
##################################################################################################### | |
# curl -s http://www.nationalrail.co.uk/static/documents/content/station_codes.csv | grep '<PLACE>' # | |
##################################################################################################### | |
# Example usage with all 4 arguments passed: | |
############################## | |
# trains LVC MAN 0728 211015 # | |
############################## | |
function trains() { | |
FROM=${1:-LDS}; | |
TO=${2:-KGX}; | |
TIME=${3:-$(date +%H%M)}; | |
DATE=${4:-today}; | |
URL=http://ojp.nationalrail.co.uk/service/timesandfares/$FROM/$TO/$DATE/$TIME/dep; | |
open $URL | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment