Created
April 10, 2013 17:07
-
-
Save amyreese/5356501 to your computer and use it in GitHub Desktop.
Dotfile profile setup script and .gitignores
This file contains 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
*.swp | |
*~ | |
*.pyc | |
vim/.netrwhist | |
fluxbox/fbrun_history | |
fluxbox/init | |
fluxbox/lastwallpaper | |
fluxbox/log | |
fluxbox/menu.places | |
fluxbox/menu.quick | |
fluxbox/overlay | |
gnupg/gpg.conf | |
gnupg/random_seed | |
gnupg/gpg-agent-info-* | |
irssi/away.log | |
irssi/config.autosave | |
irssi/default.theme | |
irssi/fnotify | |
purple/accels | |
purple/blist.xml | |
purple/cap.db | |
purple/icons | |
purple/logs | |
purple/pounces.xml | |
ssh/id_rsa.keystore | |
ssh/known_hosts | |
xchat/scrollback | |
xchat/xchatlogs | |
znc/users/*/moddata/log/*.log | |
sublime/*.sublime_session | |
sublime/*.cache | |
sublime/Packages/* | |
!sublime/Packages/User | |
sublime/Packages/User/SFTP.errors.log | |
sublime/Packages/User/Package Control.last-run | |
sublime/Pristine Packages | |
sublime/Installed Packages | |
sublime/Backup |
This file contains 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 python2 | |
from os import path | |
import os, sys, shutil | |
settings = { | |
"source": "~/profile", | |
"target": "~", | |
} | |
def item( name, link=None ): | |
"""Symlink a profile item found in 'source' with the given 'name'. | |
By default, 'source' is the current directory, and 'target' is | |
'name' prepended with a period.""" | |
if None == name: | |
print "Null name!" | |
sys.exit(2) | |
if None == link: | |
link = "." + name | |
source = path.expanduser(settings["source"]) | |
target = path.expanduser(settings["target"]) | |
sourceItem = path.join( source, name ) | |
targetItem = path.join( target, link ) | |
print "Processing '" + sourceItem + "' -> '" + targetItem + "' ..." | |
if not path.lexists( sourceItem ): | |
print "Source '" + sourceItem + "' not found." | |
return | |
targetDir = path.dirname( targetItem ) | |
if not path.lexists( targetDir ): | |
print "Target parent '" + targetDir + "' does not exist; creating..." | |
os.makedirs( targetDir ) | |
if path.lexists( targetItem ): | |
print "Target '" + targetItem + "' already exists; deleting..." | |
if path.islink( targetItem ) or path.isfile( targetItem ): | |
os.unlink( targetItem ) | |
elif path.isdir( targetItem ): | |
try: | |
os.rmdir( targetItem ) | |
except OSError: | |
shutil.rmtree( targetItem ) | |
os.symlink( sourceItem, targetItem ) | |
#end | |
def item_tuple( tuple ): | |
length = len( tuple ) | |
if length == 2: | |
item( tuple[0], tuple[1] ) | |
elif length == 1: | |
item( tuple[0] ) | |
else: | |
print "Bad tuple: " + tuple | |
#end | |
def profile_items( source="~/profile" ): | |
settings["source"] = source | |
items = [ | |
# Regular dotfiles | |
( "alias", ), | |
( "bashrc", ), | |
( "gitconfig", ), | |
( "gitignore", ), | |
( "profile", ), | |
( "screenrc", ), | |
( "screenrc.irssi", ), | |
( "sieverc", ), | |
( "synergy.conf", ), | |
( "tmux.conf", ), | |
( "vimrc", ), | |
( "xmodmaprc", ), | |
( "zshrc", ), | |
# Regular dotdirs | |
( "fonts", ), | |
( "gnupg", ), | |
( "irssi", ), | |
( "oh-my-zsh", ), | |
( "purple", ), | |
( "vim", ), | |
# Other | |
( "bin", "bin" ), | |
( "xchat", ".xchat2" ), | |
( "ssh/authorized_keys", ".ssh/authorized_keys" ), | |
( "ssh/config", ".ssh/config" ), | |
( "htoprc", ".config/htop/htoprc" ), | |
( "sublime", ".config/sublime-text-2" ), | |
] | |
map( item_tuple, items ); | |
#end | |
if __name__ == "__main__": | |
profilepath = path.abspath( path.dirname( path.dirname( sys.argv[0] ) ) ) | |
if profilepath != "": | |
profile_items( source=profilepath ) | |
else: | |
profile_items() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment