-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
executable file
·80 lines (68 loc) · 2.37 KB
/
init.py
File metadata and controls
executable file
·80 lines (68 loc) · 2.37 KB
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
#! /usr/bin/env python
import sys;
import os;
import shutil;
import subprocess;
basePath = os.path.dirname(os.path.realpath(__file__));
def install_vim_plugin(plugindir, branch=False):
externals_dir = os.getcwd()+"/externals";
pluginpath = externals_dir+"/"+plugindir;
targetpath = os.environ["HOME"]+"/.vim/"
print "Updating plugin from git";
if not branch:
branch = 'master';
curdir = os.getcwd();
os.chdir(pluginpath);
os.system('git pull origin '+branch);
print "Installing vim plugin at " + pluginpath;
for item in os.listdir(pluginpath):
ignorelist = ['.git']
if item not in ignorelist:
path = pluginpath+"/"+item;
if os.path.isdir(path):
cmd = 'cp -R ' + path + ' ' + targetpath;
os.system(cmd);
os.chdir(curdir);
def create_link(targetname, srcdir, singlefile=False):
if singlefile == True:
lntarget = os.environ["HOME"]+"/"+srcdir+"/"+targetname;
else:
lntarget = os.environ["HOME"]+"/"+targetname;
if not os.path.exists(lntarget):
if not os.path.exists(os.path.dirname(lntarget)):
print "Directory " + os.path.dirname(lntarget) + " does not exist, creating it";
os.mkdir(os.path.dirname(lntarget));
print "Symlinking " + targetname + "...";
os.symlink(basePath+"/"+srcdir+"/"+targetname, lntarget);
else:
print lntarget + " already exists";
cmd = "git submodule init".split(" ");
process = subprocess.Popen(cmd, stdout=subprocess.PIPE);
for line in process.stdout:
print line;
process.wait();
cmd = "git submodule update".split(" ");
process = subprocess.Popen(cmd, stdout=subprocess.PIPE);
for line in process.stdout:
print line;
process.wait();
create_link('.tmux.conf', 'tmux');
create_link('.vimrc', 'vim');
create_link('.vim', 'vim');
create_link('.ackrc', 'ack');
create_link('.gitconfig', 'git');
create_link('sessions', 'tmux');
create_link('.global_ignore', 'git');
# For bash take the existing .bashrc rename it and relink it as .bashrc.local then link in this bashrc
bashrc = os.environ["HOME"]+"/.bashrc";
bashrclocal = os.environ["HOME"]+"/.bashrc.local";
if not os.path.exists(bashrclocal):
print "Moving " + bashrc + "...";
os.rename(bashrc, bashrclocal);
create_link('.bashrc', 'bash');
# Adding in git-completion.bash
create_link('git-completion.bash', 'bash');
create_link('tmux-completion.bash', 'bash');
create_link('tmux-sessions.bash', 'bash');
create_link('git_diff_wrapper', 'bin', True);
create_link('killsess', 'bin', True);