]> git.phdru.name Git - dotfiles.git/commitdiff
Refactor loop
authorOleg Broytman <phd@phdru.name>
Fri, 17 Jan 2014 22:25:29 +0000 (02:25 +0400)
committerOleg Broytman <phd@phdru.name>
Fri, 17 Jan 2014 22:25:29 +0000 (02:25 +0400)
lib/python/init.py

index 26692bbf3a77fd8ac1ec1c0ae7f5b95d8f485b62..d835c1c9a39b78edc9946c54dc31f688a3fb4b4b 100644 (file)
@@ -59,40 +59,42 @@ def init():
 
     # From Randall Hopper
 
-        if _term in term:
-            if background == 'dark':
-                ps1_color = '3' # yellow
-                stdout_color = '7' # bold white
-            else:
-                ps1_color = '4' # blue
-                stdout_color = '0' # bold black
     for _term in ['linux', 'rxvt', 'screen', 'term', 'vt100']:
+        if _term not in term:
+            continue
+
+        if background == 'dark':
+            ps1_color = '3' # yellow
+            stdout_color = '7' # bold white
+        else:
+            ps1_color = '4' # blue
+            stdout_color = '0' # bold black
 
-            sys.ps1 = '\001\033[3%sm\002>>>\001\033[0m\002 ' % ps1_color
-            sys.ps2 = '\001\033[1;32m\002...\001\033[0m\002 ' # bold green
+        sys.ps1 = '\001\033[3%sm\002>>>\001\033[0m\002 ' % ps1_color
+        sys.ps2 = '\001\033[1;32m\002...\001\033[0m\002 ' # bold green
 
 
-            # From Denis Otkidach
+        # From Denis Otkidach
 
-            class ColoredFile:
-                def __init__(self, fp, begin, end='\033[0m'): # reset all attributes
-                    self.__fp = fp
-                    self.__begin = begin
-                    self.__end = end
+        class ColoredFile:
+            def __init__(self, fp, begin, end='\033[0m'): # reset all attributes
+                self.__fp = fp
+                self.__begin = begin
+                self.__end = end
 
-                def write(self, s):
-                    self.__fp.write(self.__begin+s+self.__end)
+            def write(self, s):
+                self.__fp.write(self.__begin+s+self.__end)
 
-                def writelines(self, lines):
-                    map(self.write, lines)
+            def writelines(self, lines):
+                map(self.write, lines)
 
-                def __getattr__(self, attr):
-                    return getattr(self.__fp, attr)
+            def __getattr__(self, attr):
+                return getattr(self.__fp, attr)
 
-            sys.stdout = ColoredFile(sys.stdout, '\033[1;3%sm' % stdout_color)
-            sys.stderr = ColoredFile(sys.stderr, '\033[31m') # red
+        sys.stdout = ColoredFile(sys.stdout, '\033[1;3%sm' % stdout_color)
+        sys.stderr = ColoredFile(sys.stderr, '\033[31m') # red
 
-            break
+        break
 
     try:
         import locale