commit 00971913a22cb027ccca70d39c291a14143b0fa4 Author: Artem Sapegin Date: Wed Oct 10 16:51:59 2012 +0400 initial commit diff --git a/gitattributes b/gitattributes new file mode 100644 index 0000000..0a91f75 --- /dev/null +++ b/gitattributes @@ -0,0 +1,2 @@ +# Automatically normalize line endings for all text-based files +* text=auto diff --git a/gitconfig b/gitconfig new file mode 100644 index 0000000..c18daeb --- /dev/null +++ b/gitconfig @@ -0,0 +1,55 @@ +[color] + ui = auto +[color "diff"] + meta = blue bold + frag = black bold + old = red bold + new = magenta bold +[core] + editor = nano + # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines + # If doesn't work, try: pager = less -+$LESS -FRX + pager = less -r + autocrlf = false + excludesfile = ~/.gitignore + attributesfile = ~/.gitattributes +[alias] + a = add + ua = reset HEAD + b = branch + c = commit + ca = commit -a + cam = commit -am + co = checkout + d = diff --color-words + s = status -sb + l = log --graph --pretty=format:'%C(magenta)%h%C(blue)%d%Creset %s %C(blue bold)- %an, %ar%Creset' + ll = log --stat --abbrev-commit + ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $2 >> .gitignore + this = !git init && git add . && git commit -m \"initial commit\" + amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend +[push] + default = current + +# URL shorthands +[url "git@github.com:"] + insteadOf = "gh:" + pushInsteadOf = "github:" + pushInsteadOf = "git://github.com/" +[url "git://github.com/"] + insteadOf = "github:" +[url "git@gist.github.com:"] + insteadOf = "gst:" + pushInsteadOf = "gist:" + pushInsteadOf = "git://gist.github.com/" +[url "git://gist.github.com/"] + insteadOf = "gist:" + +# Include local settings +# Example: +# [user] +# name = Artem Sapegin +# email = artem@sapegin.ru +[include] + path = ~/.gitlocal + diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..80220c9 --- /dev/null +++ b/gitignore @@ -0,0 +1,17 @@ +# Compiled Python files +*.pyc + +# Folder view configuration files +.DS_Store +Desktop.ini + +# Thumbnail cache files +._* +Thumbs.db + +# Files that might appear on external disks +.Spotlight-V100 +.Trashes + +# Installed NPM modules +node_modules \ No newline at end of file diff --git a/sync.py b/sync.py new file mode 100755 index 0000000..0aec13c --- /dev/null +++ b/sync.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +""" +Dotfiles syncronization. +Makes symlinks for all files: ./bashrc will by available as ~/.bashrc. +Source: https://gist.github.com/490016 +""" + +import os +import glob + +EXCLUDE = ['sync.py'] +NO_DOT_PREFIX = ['bin'] + +def force_remove(path): + if os.path.isdir(path) and not os.path.islink(path): + shutil.rmtree(path, False, on_error) + else: + os.unlink(path) + +def is_link_to(link, dest): + is_link = os.path.islink(link) + is_link = is_link and os.readlink(link).rstrip('/') == dest.rstrip('/') + return is_link + +def main(): + os.chdir(os.path.dirname(os.path.abspath(__file__))) + for filename in [file for file in glob.glob('*') if file not in EXCLUDE]: + dotfile = filename + if filename not in NO_DOT_PREFIX: + dotfile = '.' + dotfile + dotfile = os.path.join(os.path.expanduser('~'), dotfile) + source = os.path.relpath(filename, os.path.dirname(dotfile)) + + # Check that we aren't overwriting anything + if os.path.exists(dotfile): + if is_link_to(dotfile, source): + continue + + response = raw_input("Overwrite file `%s'? [y/N] " % dotfile) + if not response.lower().startswith('y'): + print "Skipping `%s'..." % dotfile + continue + + force_remove(dotfile) + + os.symlink(source, dotfile) + print "%s => %s" % (dotfile, source) + +if __name__ == '__main__': + main() \ No newline at end of file