# -*- coding: utf-8 -*-

from powerline.renderer import Renderer


class TerminalRenderer(Renderer):
	'''Powerline terminal segment renderer.'''
	def hl(self, fg=None, bg=None, attr=None):
		'''Highlight a segment.

		If an argument is None, the argument is ignored. If an argument is
		False, the argument is reset to the terminal defaults. If an argument
		is a valid color or attribute, it's added to the ANSI escape code.
		'''
		ansi = []
		if fg is not None:
			if fg[0] is False:
				ansi += [39]
			else:
				ansi += [38, 5, fg[0]]
		if bg is not None:
			if bg[0] is False:
				ansi += [49]
			else:
				ansi += [48, 5, bg[0]]
		if attr is not None:
			if attr is False:
				ansi += [22]
			else:
				if attr & Renderer.ATTR_BOLD:
					ansi += [1]
		return '[{0}m'.format(';'.join(str(attr) for attr in ansi))

@@ -18,16 +18,27 @@
 -8 -*-%0A%0A
+import os%0A%0A
 from pow
@@ -149,16 +149,336 @@
 rer.'''%0A
+%09_color_templates = %7B%0A%09%09'default': '%1B%5B%7Bcode%7Dm',%0A%09%09'bash': '%5C%5B%1B%5B%7Bcode%7Dm%5C%5D',%0A%09%09'zsh': '%25%7B%7B%1B%5B%7Bcode%7Dm%25%7D%7D',%0A%09%7D%0A%0A%09def __init__(self, *args, **kwargs):%0A%09%09super(TerminalRenderer, self).__init__(*args, **kwargs)%0A%09%09shell = os.path.basename(os.environ.get('SHELL', 'default'))%0A%09%09self.color_template = self._color_templates%5Bshell%5D%0A%0A
 %09def hl(
@@ -1094,24 +1094,35 @@
 urn 
-'%1B%5B%7B0%7Dm'
+self.color_template
 .format(
 ';'.
@@ -1117,16 +1117,21 @@
 .format(
+code=
 ';'.join

Update terminal renderer output depending on shell