Avoid color config in tako if noninteractive
This commit is contained in:
parent
fb5fe16867
commit
3ddaa4572a
1 changed files with 47 additions and 46 deletions
|
|
@ -40,58 +40,59 @@ $TAKO_SETTINGS.aliases.update({
|
|||
'workon': _workon,
|
||||
})
|
||||
|
||||
if '256color' in $TERM:
|
||||
colors = {
|
||||
'blue': 81,
|
||||
'orange': 166,
|
||||
'purple': 135,
|
||||
'red': 196,
|
||||
'green': 118,
|
||||
'gray': 241,
|
||||
}
|
||||
if 'TERM' in __tako_env__:
|
||||
if '256color' in $TERM:
|
||||
colors = {
|
||||
'blue': 81,
|
||||
'orange': 166,
|
||||
'purple': 135,
|
||||
'red': 196,
|
||||
'green': 118,
|
||||
'gray': 241,
|
||||
}
|
||||
|
||||
def colorize(color, text):
|
||||
prefix = '{COLOR_' + str(colors[color]) + '}'
|
||||
suffix = '{NO_COLOR}'
|
||||
return prefix + text + suffix
|
||||
else:
|
||||
colors = {
|
||||
'blue': 'BLUE',
|
||||
'orange': 'YELLOW',
|
||||
'purple': 'PURPLE',
|
||||
'red': 'RED',
|
||||
'green': 'GREEN',
|
||||
'gray': 'WHITE',
|
||||
}
|
||||
def colorize(color, text):
|
||||
prefix = '{%s}' % colors[color]
|
||||
suffix = '{NO_COLOR}'
|
||||
return prefix + text + suffix
|
||||
def colorize(color, text):
|
||||
prefix = '{COLOR_' + str(colors[color]) + '}'
|
||||
suffix = '{NO_COLOR}'
|
||||
return prefix + text + suffix
|
||||
else:
|
||||
colors = {
|
||||
'blue': 'BLUE',
|
||||
'orange': 'YELLOW',
|
||||
'purple': 'PURPLE',
|
||||
'red': 'RED',
|
||||
'green': 'GREEN',
|
||||
'gray': 'WHITE',
|
||||
}
|
||||
def colorize(color, text):
|
||||
prefix = '{%s}' % colors[color]
|
||||
suffix = '{NO_COLOR}'
|
||||
return prefix + text + suffix
|
||||
|
||||
def git_branch():
|
||||
ref=$(git symbolic-ref HEAD err> /dev/null)
|
||||
if not ref: return None
|
||||
prefix = colorize('gray', ':')
|
||||
branch = colorize('orange', re.sub('^refs/heads/', '', ref[0].strip()))
|
||||
return prefix + branch
|
||||
def git_branch():
|
||||
ref=$(git symbolic-ref HEAD err> /dev/null)
|
||||
if not ref: return None
|
||||
prefix = colorize('gray', ':')
|
||||
branch = colorize('orange', re.sub('^refs/heads/', '', ref[0].strip()))
|
||||
return prefix + branch
|
||||
|
||||
$TAKO_SETTINGS.prompt_fields['git_branch'] = git_branch
|
||||
$TAKO_SETTINGS.prompt_fields['git_branch'] = git_branch
|
||||
|
||||
def make_prompt():
|
||||
username = colorize('purple', '{user}')
|
||||
host = colorize('blue', '{hostname}')
|
||||
directory = colorize('green', '{cwd}')
|
||||
lbrkt = colorize('gray', '[')
|
||||
rbrkt = colorize('gray', ']')
|
||||
colon = colorize('gray', ':')
|
||||
def make_prompt():
|
||||
username = colorize('purple', '{user}')
|
||||
host = colorize('blue', '{hostname}')
|
||||
directory = colorize('green', '{cwd}')
|
||||
lbrkt = colorize('gray', '[')
|
||||
rbrkt = colorize('gray', ']')
|
||||
colon = colorize('gray', ':')
|
||||
|
||||
return lbrkt + colon.join([
|
||||
username,
|
||||
host,
|
||||
directory,
|
||||
]) + '{git_branch}' + rbrkt + '\n{prompt_end} '
|
||||
return lbrkt + colon.join([
|
||||
username,
|
||||
host,
|
||||
directory,
|
||||
]) + '{git_branch}' + rbrkt + '\n{prompt_end} '
|
||||
|
||||
$TAKO_SETTINGS.prompt = make_prompt()
|
||||
$TAKO_SETTINGS.prompt = make_prompt()
|
||||
|
||||
$TAKO_SETTINGS.show_traceback = True
|
||||
$TAKO_SETTINGS.traceback_logfile = $HOME + '/tmp/tako.log'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue