-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
executable file
·112 lines (91 loc) · 2.82 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
import os
import sys
if 'linux' in sys.platform:
PLATFORM = 'linux'
else:
PLATFORM = 'mac'
# no Win support
here = os.path.abspath(os.path.dirname(__file__))
home = os.path.expanduser('~')
# (src filename, dest filename)
FILES_TO_LINK = (
('bundles.vim', '.bundles.vim'),
('gitconfig', '.gitconfig'),
('gitignore', '.gitignore'),
('hgignore', '.hgignore'),
('hgrc', '.hgrc'),
('inputrc', '.inputrc'),
('linux_aliases' if PLATFORM == 'linux' else 'mac_aliases', '.aliases'),
('pythonrc', '.pythonrc'),
('refpasterc', '.refpasterc'),
('tmux.conf', '.tmux.conf'),
('vimrc', '.vimrc'),
)
# files that need to be created
EMPTY_FILES = (
'.python_history',
)
def setup_oh_my_zsh():
os.system('git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh')
if PLATFORM == 'linux':
zshrc = os.path.join(here, 'linux_zshrc')
else:
zshrc = os.path.join(here, 'mac_zshrc')
dest = os.path.join(home, '.zshrc')
try:
os.symlink(zshrc, dest)
except:
print("Trouble linking %s to %s." % (zshrc, dest))
else:
print("Linked %s to %s." % (zshrc, dest))
bindir = os.path.expanduser('~/bin')
try:
os.mkdir(bindir)
except:
print("Trouble creating %s." % bindir)
else:
print("Created empty %s." % bindir)
# add starter .paths file with ~/bin
paths = os.path.join(home, '.paths')
try:
with open(paths, 'w') as f:
f.write(bindir + '\n')
f.write(os.path.expanduser('~/localCode/go/bin'))
except:
print("Trouble creating %s." % paths)
else:
print("Created %s." % paths)
# set default
print("Setting zsh as the default shell..")
os.system('chsh -s `which zsh`')
def setup_vundle():
os.system('git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle')
print("Cloned vundle, don't forget to run 'upvim' ;)")
def main():
for src, dest in FILES_TO_LINK:
abs_src = os.path.join(here, src)
abs_dest = os.path.join(home, dest)
try:
os.symlink(abs_src, abs_dest)
except:
print("Trouble linking %s to %s." % (abs_src, abs_dest))
else:
print("Linked %s to %s." % (abs_src, abs_dest))
for filename in EMPTY_FILES:
path = os.path.join(home, filename)
try:
open(path, 'w').close()
except:
print("Trouble creating empty file %s." % path)
else:
print("Created empty file %s." % path)
setup_oh_my_zsh()
setup_vundle()
print("Done! Don't forget to set up ssh and gpg.")
if __name__ == '__main__':
print("Make sure you have git and zsh installed.")
# Support a dummy noinput flag.
if len(sys.argv) == 1:
input("Press enter.. ")
main()