1
0
Fork 0

Avoid color config in tako if noninteractive

This commit is contained in:
Jeremy Kaplan 2017-01-05 11:11:32 -08:00
commit 3ddaa4572a

View file

@ -40,7 +40,8 @@ $TAKO_SETTINGS.aliases.update({
'workon': _workon,
})
if '256color' in $TERM:
if 'TERM' in __tako_env__:
if '256color' in $TERM:
colors = {
'blue': 81,
'orange': 166,
@ -54,7 +55,7 @@ if '256color' in $TERM:
prefix = '{COLOR_' + str(colors[color]) + '}'
suffix = '{NO_COLOR}'
return prefix + text + suffix
else:
else:
colors = {
'blue': 'BLUE',
'orange': 'YELLOW',
@ -68,16 +69,16 @@ else:
suffix = '{NO_COLOR}'
return prefix + text + suffix
def git_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():
def make_prompt():
username = colorize('purple', '{user}')
host = colorize('blue', '{hostname}')
directory = colorize('green', '{cwd}')
@ -91,7 +92,7 @@ def make_prompt():
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'