DEV Community

Discussion on: Show me your Bash Functions / Aliases!

Collapse
 
lbonanomi profile image
lbonanomi • Edited

Do you use Github gists as a notebook?

gist ()
{
    GISTTMP=$(mktemp -d) && GISTFILE=$(basename $1) && GISTPATH=$(readlink -f $1)
    GIST_URL=$((echo curl -snk -X POST -d \'{\"files\":{\"$GISTFILE\":{\"content\":\".\"}}}\' https://api.github.com/gists | sh ) | awk -F'"' '/git_pull_url/ { print $4 }' | head -1 )
    (
        cd $GISTTMP
        git clone -q $GIST_URL
        cd $(ls)
        cat $GISTPATH > $GISTFILE;
        git add $GISTFILE && git commit -q -a -m "$GISTFILE" && git push -q
    )
}

Collapse
 
lbonanomi profile image
lbonanomi

I also work with throwaway-VMs, so you may do well rm -rf-ing $GISTTMP when you're done