Skip to content

Instantly share code, notes, and snippets.

@oliveiraev
Created March 8, 2019 04:17
Show Gist options
  • Save oliveiraev/9ef7855d2ef8b19d8299ec0ef05592cb to your computer and use it in GitHub Desktop.
Save oliveiraev/9ef7855d2ef8b19d8299ec0ef05592cb to your computer and use it in GitHub Desktop.
git-helpers
#!/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
#!/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