Created
March 8, 2019 04:17
-
-
Save oliveiraev/9ef7855d2ef8b19d8299ec0ef05592cb to your computer and use it in GitHub Desktop.
git-helpers
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
#!/usr/bin/env /bin/bash | |
set -e | |
function writeHeader () { | |
python3 - ${1} <<EOF | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
lines = [ | |
'', | |
'', | |
'', | |
'{:#^80}'.format(''), | |
'{:#^80}'.format('{: ^78}'.format('')), | |
'{:#<80}'.format('# {: ^77}'.format(sys.argv[1])), | |
'{:#^80}'.format('{: ^78}'.format('')), | |
'{:#^80}'.format(''), | |
'', | |
'%s', | |
'', | |
'{:#^80}'.format(''), | |
] | |
sys.stdout.write(os.linesep.join(lines)) | |
EOF | |
} | |
url=https://raw.github.com/alexkaratarakis/gitattributes/master/${1}.gitattributes | |
format=$(writeHeader ${url}) | |
contents=$(curl -f -L -# ${url}) | |
printf "${format}" "${contents}" | dd of=.gitattributes oflag=append conv=notrunc status=none | |
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
#!/usr/bin/env /bin/bash | |
set -e | |
function writeHeader () { | |
python3 - ${1} <<EOF | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
lines = [ | |
'', | |
'', | |
'', | |
'{:#^80}'.format(''), | |
'{:#^80}'.format('{: ^78}'.format('')), | |
'{:#<80}'.format('# {: ^77}'.format(sys.argv[1])), | |
'{:#^80}'.format('{: ^78}'.format('')), | |
'{:#^80}'.format(''), | |
'', | |
'%s', | |
'', | |
'{:#^80}'.format(''), | |
] | |
sys.stdout.write(os.linesep.join(lines)) | |
EOF | |
} | |
url=https://raw.github.com/github/gitignore/master/${1}.gitignore | |
format=$(writeHeader ${url}) | |
contents=$(curl -f -L -# ${url}) | |
printf "${format}" "${contents}" | dd of=.gitignore oflag=append conv=notrunc status=none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment