diff --git a/grimshot/grimshot b/grimshot/grimshot index 78d216a..ffe1be4 100755 --- a/grimshot/grimshot +++ b/grimshot/grimshot @@ -11,7 +11,39 @@ ## Those are needed to be installed, if unsure, run `grimshot check` ## ## See `man 1 grimshot` or `grimshot usage` for further details. -. ./functional-helpers + +when() { + condition=$1 + action=$2 + + if eval "$condition"; then + eval "$action" + fi +} + +whenOtherwise() { + condition=$1 + true_action=$2 + false_action=$3 + + if eval "$condition"; then + eval "$true_action" + else + eval "$false_action" + fi +} + +any() { + for tuple in "$@"; do + condition=$(echo "$tuple" | cut -d: -f1) + action=$(echo "$tuple" | cut -d: -f2-) + if eval "$condition"; then + eval "$action" + return 0 + fi + done + return 1 # No conditions matched +} NOTIFY=no CURSOR=