#!/bin/sh fzf=${YATT_FZF:="fzf --ansi"} fzfm=${YATT_FZF_MULTI:="fzf --ansi -m"} script_executable=${yatt_script_executable:=$0} usage () { echo "\ $usage_prefix with preferred fuzzy finder. By default, 'fzf' is used, but you can change it by setting \ YATT_FZF environment variable value. USAGE: $script_executable [SUBCOMMAND] SUBCOMMANDS: task Handles tasks group Handles groups interval Handles intervalsa theme Handles themes help Prints this message FLAGS: -m Multiselect " exit 0 } error () { echo "Error: invalid argument. Type \ '$script_executable help' to get list of possible commands." exit 1 } [ -z "$1" ] && usage [ "$1" != "help" ] || usage command=$1 if [ "$command" == "-m" ]; then command=$2 fzf=$fzfm fi echo $command | grep -E '^task|interval|group|theme$' > /dev/null || error if [ "$command" == "theme" ]; then command="themes list" while read -r line; do line=$(echo $line | grep -E '[0-9a-z\-]+' -o) if [ "$res" != "" ]; then res="$res,$line" else res="$line" fi done <<< $(yatt $command | $fzf) else command=${command}s command="list ${command/groups/"tasks -g"}" while read -r line; do line="${line%%]*}" line="${line#[}" if [ "$res" != "" ]; then res="$res,$line" else res="$line" fi done <<< $(yatt $command | $fzf) fi echo "${res#[}"