g['decorated_name'] = color_func(c['DECORATED_NAME'])('[' + name + ']: ')
g['ascii_art'] = True
- files = os.listdir('rainbowstream/colorset')
+ files = os.listdir(os.path.dirname(__file__)+'/colorset')
themes = [f.split('.')[0] for f in files if f.split('.')[-1] == 'json']
themes += ['custom']
g['themes'] = themes
os.environ.get('USERPROFILE',
'')) + os.sep + '.rainbow_config.json'
if not os.path.exists(custom_path):
- line += light_magenta(' (create your own config at ~/.rainbow_config.json)')
+ line += light_magenta(' (create your own config file at ~/.rainbow_config.json)')
else:
line += light_magenta(' (loaded)')
else:
# Change theme
try:
# Load new config
- new_config = 'rainbowstream/colorset/' + g['stuff'] + '.json'
+ if g['stuff'] != 'custom':
+ new_config = os.path.dirname(__file__) + '/colorset/' + g['stuff'] + '.json'
+ else:
+ new_config = os.environ.get(
+ 'HOME',os.environ.get(
+ 'USERPROFILE',
+ '')) + os.sep + '.rainbow_config.json'
new_config = load_config(new_config)
if new_config:
for nc in new_config:
c[nc] = new_config[nc]
# Update db and reset colors
db.theme_update(g['stuff'])
- cyc = init_cycle()
+ c['theme'] = g['stuff']
+ notify_cycle()
g['decorated_name'] = color_func(
c['DECORATED_NAME'])(
'[@' + g['original_name'] + ']: ')
printNicely(green('Theme changed.'))
except:
- printNicely(red('Sorry, can not load config file!'))
+ if g['stuff'] == 'custom':
+ printNicely(red('~/.rainbow_config.json is not exists!'))
+ else:
+ printNicely(red('No such theme exists.'))
def help():