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() {
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