From: Cian Bagshaw Date: Fri, 26 May 2023 09:18:04 +0000 (+0100) Subject: Allowed for multiple stop selection, and tidied function calls X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=3d7473990088302c33732870ca96f232aa3a2bb1;p=buseir Allowed for multiple stop selection, and tidied function calls --- diff --git a/buseir b/buseir index 3558d60..2e192a2 100755 --- a/buseir +++ b/buseir @@ -6,12 +6,12 @@ SITE=https://buseireann.ie CACHE=$XDG_CACHE_HOME/buseir TMP=/tmp/buseir -menu() { fzf --reverse --height=12; } +menu() { fzf -m --reverse --height=12; } readCsv() { if [ "$2" = "all" ]; - then cat "$1"; else grep "$2" "$1" - fi | cut -d, -f"$3" | tr -d \" + then cat "$1"; else grep "[\"^,]$2[\"$,]" "$1" + fi | cut -d, -f "$3" | tr -d \" } sync() { @@ -33,20 +33,20 @@ sync() { stops() { case "$2" in - name) COL=1;; num) COL=2;; duid) COL=3;; - pos) COL=4-5;; all) COL=1-;; *) COL=1;; - esac + all) COL=1-;; num) COL=2;; duid) COL=3;; + pos) COL=4-5;; *) COL=1;; + esac readCsv "$CACHE"/stops.csv "$1" "$COL" } printStop() { - sed -e '1s/^/Name:\t/; 2s/^/Number:\t/; 3s/^/DUID:\t/' \ - -e '4{N; s/\n/,/; s/^/Map:\thttps:\/\/www.google.com\/maps\/place\//}' + sed -e 's/^/Name:\t/; 1!s/^/\n/; s/,/\nNumber:\t/; s/,/\nDUID:\t/' \ + -e 's/,/\nMap:\thttps:\/\/www.google.com\/maps\/place\//' } [ ! -d "$CACHE" ] && mkdir -p "$CACHE" && sync case "$1" in sync) sync;; - stops) stops "\"$(stops all | menu)\"" all | tr "," "\n" | printStop;; + stops) stops "$(stops all | menu)" all | printStop;; esac