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
|
import os.path
from fabric.api import get, put, run
from fabric.contrib.files import exists as file_exists
KNOWN_FILES = {
'bashrc': '.bashrc',
'htoprc': '.htoprc',
'screenrc': '.screenrc',
'toprc': '.toprc',
'vimrc': '.vimrc',
}
KNOWN_TERMINFOS = [ 'rxvt-unicode', 'rxvt-unicode-256color', 'screen-256color' ]
def _terminfo_paths(terminfo):
'''Returns a (system, user) tuple of paths for where this terminfo file
belongs on a system.'''
first = terminfo[0]
system = '/usr/share/terminfo/%s/%s' % (first, terminfo)
user = '.terminfo/%s/%s' % (first, terminfo)
return (system, user)
def put_terminfo(names=None):
if names:
names = names.split(';')
else:
names = KNOWN_TERMINFOS
for name in names:
system_path, user_path = _terminfo_paths(name)
# Put file if system doesn't have it, else remove it
if file_exists(system_path):
if file_exists(user_path):
run('rm %s' % user_path)
else:
run('mkdir -p %s' % os.path.dirname(user_path))
put(name, user_path)
def put_configs(files=None):
if files:
files = files.split(';')
else:
files = KNOWN_FILES.keys()
for key in files:
value = KNOWN_FILES[key]
put(key, value)
def put_all(files=None):
put_terminfo()
put_configs(files)
def get_configs(files=None):
if files:
files = files.split(';')
else:
files = KNOWN_FILES.values()
for filename in files:
if not filename.startswith('.'):
filename = '.%s' % filename
get(filename)
# vim: set ts=4 sw=4 et:
|