Remove hard-coded colors

This commit is contained in:
Arun Prakash Jana 2017-08-25 03:00:45 +05:30
parent c9d15b4c98
commit 3b0bd1c054
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 15 additions and 12 deletions

View File

@ -246,6 +246,8 @@ PROMPT KEYS:
q, ^D, double Enter exit buku
```
`buku` supports custom colors. Visit the wiki page on how to [customize colors](https://github.com/jarun/Buku/wiki/Customize-colors) for more details.
### Examples
1. **Edit and add** a bookmark from editor:

10
buku.1
View File

@ -347,14 +347,14 @@ index
.IP - 2
title
.IP - 2
url
URL
.IP - 2
description
description/comment/note
.IP - 2
tag
.PD 1 \" Restore paragraph spacing
.TP
respectively. The five-letter string is passed is as the argument to the \fB--colors\fR option.
respectively. The five-letter string is passed is as the argument to the \fB--colors\fR option, or as the value of the environment variable \fBBUKU_COLORS\fR.
.TP
We offer the following colors/styles:
.TS
@ -395,9 +395,9 @@ bright cyan index
.IP - 2
bold bright green title
.IP - 2
bright yellow url
bright yellow URL
.IP - 2
comments/notes/desc - normal
normal description
.IP - 2
bright blue tag
.PD 1 \" Restore paragraph spacing

15
buku.py
View File

@ -49,13 +49,12 @@ SKIP_MIMES = {'.pdf', '.txt'}
colorize = True # Allow color output by default
# Default colour to print records
ID = '\x1b[96m%d. \x1b[0m'
ID_str = ID + '\x1b[1;92m%s\x1b[0;2m [%s]\x1b[0m\n'
ID_DB_str = ID + '\x1b[1;92m%s\x1b[0m'
ID_str = ''
ID_DB_str = ''
MUTE_str = '%s \x1b[2m(L)\x1b[0m\n'
URL_str = '%s \x1b[91m>\x1b[93m %s\x1b[0m\n'
DESC_str = '%s \x1b[91m+\x1b[0m %s\x1b[0m\n'
TAG_str = '%s \x1b[91m#\x1b[94m %s\x1b[0m\n'
URL_str = ''
DESC_str = ''
TAG_str = ''
# colormap for color output from "googler" project
COLORMAP = {k: '\x1b[%sm' % v for k, v in {
@ -3094,6 +3093,7 @@ def main():
tags_in = None
desc_in = None
pipeargs = []
colorstr_env = os.getenv('BUKU_COLORS')
try:
piped_input(sys.argv, pipeargs)
@ -3259,7 +3259,8 @@ POSITIONAL ARGUMENTS:
addarg('-p', '--print', nargs='*', help=HIDE)
addarg('-f', '--format', type=int, default=0, choices={1, 2, 3, 4}, help=HIDE)
addarg('-j', '--json', action='store_true', help=HIDE)
addarg('--colors', dest='colorstr', type=argparser.is_colorstr, metavar='COLORS', help=HIDE)
addarg('--colors', dest='colorstr', type=argparser.is_colorstr,
default=colorstr_env if colorstr_env else 'oKlxm', metavar='COLORS', help=HIDE)
addarg('--nc', action='store_true', help=HIDE)
addarg('--np', action='store_true', help=HIDE)
addarg('-o', '--open', nargs='*', help=HIDE)