forked from b-ryan/powerline-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
executable file
·31 lines (27 loc) · 970 Bytes
/
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
#!/usr/bin/env python
import os
import stat
import config
TEMPLATE_FILE = 'powerline-shell.py.template'
OUTPUT_FILE = 'powerline-shell.py'
SEGMENTS_DIR = 'segments'
THEMES_DIR = 'themes'
def load_source(srcfile):
try:
return ''.join(open(srcfile).readlines()) + '\n\n'
except IOError:
print 'Could not open ' + srcfile
return ''
if __name__ == "__main__":
source = load_source(TEMPLATE_FILE)
source += load_source(os.path.join(THEMES_DIR, config.THEME + '.py'))
for segment in config.SEGMENTS:
source += load_source(os.path.join(SEGMENTS_DIR, segment + '.py'))
source += 'sys.stdout.write(powerline.draw())\n'
try:
open(OUTPUT_FILE, 'w').write(source)
st = os.stat(OUTPUT_FILE)
os.chmod(OUTPUT_FILE, st.st_mode | stat.S_IEXEC)
print OUTPUT_FILE, 'saved successfully'
except IOError:
print 'ERROR: Could not write to powerline-shell.py. Make sure it is writable'