Created
January 18, 2019 06:00
-
-
Save radditude/b02a8271a8f6c13d495dbd8158a2ade3 to your computer and use it in GitHub Desktop.
script to generate prefilled urls for Airtable forms with fuzzy matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example usage: ./airtable.sh mon edu 2 int "learning how to write bash scripts" | |
fuzz(){ | |
echo "$2" | grep -q "$1" | |
} | |
fuzzyfind(){ | |
# PROJECTS | |
if fuzz $1 content; then echo "Content" | |
elif fuzz $1 education; then echo "Education" | |
elif fuzz $1 meetings; then echo "Company Meetings" | |
# CATEGORIES | |
elif fuzz $1 implementation; then echo "Implementation" | |
elif fuzz $1 internaltime; then echo "Internal Time" | |
elif fuzz $1 projectplanning; then echo "Project Planning" | |
fi | |
} | |
tracktime(){ | |
# CONSTANTS | |
NAME="CJ Horton" | |
BASEURL="https://airtable.com/[FORM_IDENTIFIER]?prefill_Name=$NAME" | |
URL=$BASEURL | |
# INPUTS | |
DAY=$1 | |
PROJECT=$2 | |
TIME=$3 | |
CATEGORY=$4 | |
NOTES=$5 | |
if [[ "$1" == "help" ]]; then | |
echo "usage: track-time [day] [project] [hours] [category] [notes]" | |
return 1 | |
fi | |
if [ "$DAY" ]; then URL="$BASEURL&prefill_Date=$(date -v $DAY +%m/%d/%Y)" fi | |
if [ "$PROJECT" ]; then URL="$URL&prefill_Project=$(fuzzyfind $PROJECT)" fi | |
if [ "$TIME" ]; then URL="$URL&prefill_Hours=$TIME" fi | |
if [ "$NOTES" ]; then URL="$URL&prefill_Notes=$NOTES" fi | |
if [ "$CATEGORY" ]; then | |
URL="$URL&prefill_Category=$(fuzzyfind $CATEGORY)" | |
else | |
URL="$URL&prefill_Category=$DEFAULT_CATEGORY" | |
fi | |
echo $URL | |
open "$URL" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment