From c7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb Mon Sep 17 00:00:00 2001 From: zlg Date: Sat, 5 Dec 2020 22:42:32 -0800 Subject: helpers.sh: Add vgsys vgsys - filters vgstash's output by system. Optionally allows one to specify the filter name to pass to vgstash. The default filter is 'allgames'. For example, to show every game needed to be beaten on Steam, you'd use something like this: vgsys backlog Steam This is a handy feature to have when you want to narrow down your options for what-to-play. --- scripts/helpers.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'scripts') diff --git a/scripts/helpers.sh b/scripts/helpers.sh index b726f0b..69aa59a 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -54,3 +54,27 @@ function vgrand() { local game=$(vgstash list playlog | sed -e '1,2d' | shuf -n 1 --random-source=/dev/random | cut -d '|' -f 1-2 | tr -s ' ' | sed -e 's: | :, for :' -e 's:\s$::') echo "You should play ${game}!" } + +# Filters your vgstash output by system. Depends on awk +function vgsys() { + local f='allgames' + local s='' + case $# in + 1) + # single arg means we want the default filter + s="$1" + ;; + 2) + f="$1" + s="$2" + ;; + *) + echo "USAGE: vgsys [FILTER] SYSTEM" + echo + echo "Show all games from a given system (and optionally, filter)." + echo "Defaults to 'allgames' filter if the argument is missing." + return + ;; + esac + vgstash list $f -w 80 | awk 'BEGIN {FS="|"} $2 ~ /'$s'/' +} -- cgit v1.2.3-54-g00ecf