Skip to content

Instantly share code, notes, and snippets.

@radditude
Created January 18, 2019 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radditude/b02a8271a8f6c13d495dbd8158a2ade3 to your computer and use it in GitHub Desktop.
Save radditude/b02a8271a8f6c13d495dbd8158a2ade3 to your computer and use it in GitHub Desktop.
script to generate prefilled urls for Airtable forms with fuzzy matching
# 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