Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- HAMSTER=/usr/bin/hamster
- IFS=$'\n'
- function readVariable {
- unset "$1"
- while [ -z "${!1}" ]; do
- read -p "$2 name: " "$1"
- if [ -z "${!1}" ]; then
- read -p "Abort?" -n 1 -r ABORT
- echo
- if [[ $ABORT =~ ^[yY]$ ]]; then
- exit 0
- fi
- fi
- done
- }
- CATEGORIES=($($HAMSTER categories && echo '$NEW$'))
- PS3="Category: "
- select CATEGORY in "${CATEGORIES[@]}"; do
- case $CATEGORY in
- '')
- echo "Select a number between 1 and ${#CATEGORIES[@]}"
- ;;
- '$NEW$')
- readVariable CATEGORY Category
- readVariable ACTIVITY Activity
- break
- ;;
- *)
- ACTIVITIES=($($HAMSTER activities | grep $CATEGORY | cut -d'@' -f1 && echo '$NEW$'))
- PS3='Activity: '
- select ACTIVITY in "${ACTIVITIES[@]}"; do
- case $ACTIVITY in
- '')
- echo "Select a number between 1 and ${#ACTIVITIES[@]}"
- ;;
- '$NEW$')
- readVariable ACTIVITY Activity
- break
- ;;
- *)
- break
- esac
- done
- break
- ;;
- esac
- done
- IFS=' '
- read -p "Tag names: " -a TAGS
- if [ ! -z "$TAGS" ]; then
- TAGS=$(printf "#%s" "${TAGS[@]}")
- fi
- $HAMSTER track "$ACTIVITY@$CATEGORY$TAGS"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement