diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/colorcodes.py b/colorcodes.py new file mode 100644 index 0000000..6a152ee --- /dev/null +++ b/colorcodes.py @@ -0,0 +1,9 @@ +class Bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' diff --git a/t.py b/t.py index b2594f8..d7d0951 100755 --- a/t.py +++ b/t.py @@ -7,7 +7,7 @@ import os, re, sys, hashlib from operator import itemgetter from optparse import OptionParser, OptionGroup - +from colorcodes import Bcolors as bcolors class InvalidTaskfile(Exception): """Raised when the path to a task file already exists as a directory.""" @@ -227,10 +227,15 @@ def print_list(self, kind='tasks', verbose=False, quiet=False, grep=''): tasks[task_id]['prefix'] = prefix plen = max(map(lambda t: len(t[label]), tasks.values())) if tasks else 0 + + def color_print(p, task): + """Add effective color style to tasks list""" + print(bcolors.UNDERLINE+bcolors.WARNING + p + bcolors.ENDC, bcolors.OKBLUE+task+bcolors.ENDC) + for _, task in sorted(tasks.items()): if grep.lower() in task['text'].lower(): - p = '%s - ' % task[label].ljust(plen) if not quiet else '' - print(p + task['text']) + p = '<%s> - ' % task[label].ljust(plen) if not quiet else '' + color_print(p, task['text']) def write(self, delete_if_empty=False): """Flush the finished and unfinished tasks to the files on disk."""