#! /bin/bash google() ( _is_sheets() { echo "$@" | grep -q 'docs.google.com.spreadsheets' } _is_doc() { echo "$@" | grep -q 'docs.google.com.document' } is() { _is_sheets "$@" || _is_doc "$@" } human_url() { echo "$1" } get() { local cache_key="google get $*" if cache get "$cache_key"; then return 0 fi _get "$@" | cache put "$cache_key" } _get() { local url="$1" local id="${url%/*}" id="${id##*/}" local downloaded="$(rclone get_google "$id")" echo "# ${downloaded##*/}" echo "" if [ "${downloaded##*.}" == ".csv" ]; then _csv_to_md "$downloaded" fi cat "$downloaded" } _csv_to_md() { local f="$1" log _csv_to_md $f } expand() { get "$@" | head -n 1 | sed 's/^[#]* //' | base64 } "$@" )