aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2020-12-05 22:42:32 -0800
committerzlg <zlg@zlg.space>2020-12-05 22:42:32 -0800
commitc7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb (patch)
tree0e9d4890ab3aef4ac3f7706a72c6acbc3020adf1
parentsetup.py: Bump to 0.3b6 for PyPI (diff)
downloadvgstash-c7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb.tar.gz
vgstash-c7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb.tar.bz2
vgstash-c7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb.tar.xz
vgstash-c7fd0ab02cacf6eb0f73d8d59f9447ca1a9d47fb.zip
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.
-rw-r--r--scripts/helpers.sh24
1 files changed, 24 insertions, 0 deletions
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'/'
+}