Skip to content

Instantly share code, notes, and snippets.

@miraculixx
Last active March 3, 2020 18:17
Show Gist options
  • Save miraculixx/65b3f3f57f1c2c7d339331ffd8f87e4f to your computer and use it in GitHub Desktop.
Save miraculixx/65b3f3f57f1c2c7d339331ffd8f87e4f to your computer and use it in GitHub Desktop.
Makefile for multi-file gists using https://github.com/defunkt/gist
# no blank lines!
.gist
.gistignore
.git/*
.idea/*
__pycache_/*
# makefile to simplify use of gist for multi-file gists
#
# Usage:
# 1. create a .gistignore file with file patterns to ignore
# 2. make gist
#
# this will create/update the gist including all files not matched by any
# pattern in .gitignore. The URL will be printed and stored in .gist
#
# 3. make clean
#
# this will delete the gist
GISTFILES=$(shell find . -type f | grep -v -f .gistignore | xargs)
GISTID=$(shell [ -f .gist ] && cat .gist | xargs basename)
confirm:
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
gist:
@if [ -e .gist ]; then gist -u $(GISTID) $(GISTFILES); fi
@if [ ! -e .gist ]; then gist $(GISTFILES) > .gist && cat .gist; fi
clean: confirm
@if [ -e .gist ]; then gist --delete $(GISTID); fi
@rm -rf .gist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment