-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
executable file
·54 lines (34 loc) · 1.27 KB
/
install.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
#! /usr/bin/env python
import inspect, os
from subprocess import call
def run_cmd(cmd):
print "Executing system command:"
print " ".join(cmd)
call(cmd)
def create_directory(directory):
if os.path.exists(directory):
print "Exists: " + directory
else:
print "Creating " + directory
os.mkdir(directory)
def create_in_home_directory(directory):
create_directory(os.environ["HOME"] + "/" + directory)
def switch_ruby_script_path():
return os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + "/switch-ruby"
exec_paths = os.environ["PATH"].split(":")
i = 0
for path in exec_paths:
highlight = ""
if os.access(path, os.W_OK):
highlight = "\x1b[32m" #foo\x1b[0m"
print highlight + str(i) + ": " + path + "\x1b[0m"
i = i + 1
path_index = raw_input('Where should a sym-link to the switch-ruby script be created (green has write permissions): ')
run_cmd(["ln", "-nfs", switch_ruby_script_path(), exec_paths[int(path_index)] + "/"])
print "Preparing directories..."
create_in_home_directory(".rb")
create_in_home_directory(".rb/cache")
create_in_home_directory(".rb/src")
print "Finished."
print "Add the following line at the end of your ~/.bashrc file:"
print "export PATH=$HOME/.rb/bin:$PATH"