cycle-color
[rainbowstream.git] / rainbowstream / rainbow.py
index ed3d07fdf61cb0bb658a9560bf8f4651090ccc3f..d31533b029f6dbfe579a71cd0f024e8a24e55e5d 100644 (file)
@@ -139,6 +139,7 @@ def get_decorated_name():
 
     files = os.listdir('rainbowstream/colorset')
     themes = [f.split('.')[0] for f in files if f.split('.')[-1] == 'json']
+    themes += ['custom']
     g['themes'] = themes
     db.theme_store(c['theme'])
 
@@ -774,12 +775,14 @@ def theme():
             # Detect custom config
             if theme == 'custom':
                 line += light_magenta('custom')
-                exists = db.theme_query()
-                themes = [t.theme_name for t in exists]
-                if themes[0] == 'custom':
-                    line += light_magenta(' (applied)')
+                custom_path = os.environ.get(
+                    'HOME',
+                    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)')
                 else:
-                    line += light_magenta(' (not specified)')
+                    line += light_magenta(' (loaded)')
             else:
                 line += light_magenta(theme)
             if c['theme'] == theme :
@@ -796,14 +799,15 @@ def theme():
             if new_config:
                 for nc in new_config:
                     c[nc] = new_config[nc]
-            # Update db
+            # Update db and reset colors
             db.theme_update(g['stuff'])
+            cyc = init_cycle()
             g['decorated_name'] = color_func(
                 c['DECORATED_NAME'])(
                 '[@' + g['original_name'] + ']: ')
             printNicely(green('Theme changed.'))
         except:
-            printNicely(red('Sorry, config file is broken!'))
+            printNicely(red('Sorry, can not load config file!'))
 
 
 def help():