def __str__(self): zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"') zsh.eval('_POWERLINE_SHORTENED_PATH="${(%):-%~}"') segment_info = { 'args': self.args, 'environ': environ, 'client_id': 1, 'local_theme': self.theme, 'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'), 'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'), } zsh.setvalue('_POWERLINE_PARSER_STATE', None) zsh.setvalue('_POWERLINE_SHORTENED_PATH', None) try: zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT') except IndexError: zle_rprompt_indent = 1 r = '' if self.above: for line in self.powerline.render_above_lines( width=zsh.columns() - zle_rprompt_indent, segment_info=segment_info, ): r += line + '\n' r += self.powerline.render( width=zsh.columns(), side=self.side, segment_info=segment_info, ) if type(r) is not str: if type(r) is bytes: return r.decode(get_preferred_output_encoding(), 'replace') else: return r.encode(get_preferred_output_encoding(), 'replace') return r
def __str__(self): zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"') segment_info = { 'args': self.args, 'environ': environ, 'client_id': 1, 'local_theme': self.theme, 'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'), 'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'), } r = '' if self.above: for line in self.powerline.render_above_lines( width=zsh.columns() - 1, segment_info=segment_info, ): r += line + '\n' r += self.powerline.render( width=zsh.columns(), side=self.side, segment_info=segment_info, ) if type(r) is not str: if type(r) is bytes: return r.decode('utf-8') else: return r.encode('utf-8') return r
def history(pl): import zsh zsh.eval('_POWERLINE_REPLY=$(print -P "%!")') history_num = zsh.getvalue('_POWERLINE_REPLY') zsh.setvalue('_POWERLINE_REPLY', None) ret = [ { 'contents': history_num } ] return ret
def __str__(self): parser_state = u(zsh_expand('${(%):-%_}')) shortened_path = u(zsh_expand('${(%):-%~}')) try: mode = u(zsh.getvalue('_POWERLINE_MODE')) except IndexError: mode = None try: default_mode = u(zsh.getvalue('_POWERLINE_DEFAULT_MODE')) except IndexError: default_mode = None segment_info = { 'args': self.args, 'environ': environ, 'client_id': 1, 'local_theme': self.theme, 'parser_state': parser_state, 'shortened_path': shortened_path, 'mode': mode, 'default_mode': default_mode, } try: zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT') except IndexError: zle_rprompt_indent = 1 r = '' if self.above: for line in self.powerline.render_above_lines( width=zsh.columns() - zle_rprompt_indent, segment_info=segment_info, ): if line: r += line + '\n' r += self.powerline.render( width=zsh.columns(), side=self.side, segment_info=segment_info, mode=mode, ) if type(r) is not str: if type(r) is bytes: return r.decode(get_preferred_output_encoding(), 'replace') else: return r.encode(get_preferred_output_encoding(), 'replace') return r
def set_prompt(powerline, psvar, side, theme, above=False): try: savedps = zsh.getvalue(psvar) except IndexError: savedps = None zpyvar = 'ZPYTHON_POWERLINE_' + psvar prompt = Prompt(powerline, side, theme, psvar, savedps, above) zsh.set_special_string(zpyvar, prompt) zsh.setvalue(psvar, '${' + zpyvar + '}')
def set_prompt(powerline, psvar, side, theme): try: savedps = zsh.getvalue(psvar) except IndexError: savedps = None zpyvar = 'ZPYTHON_POWERLINE_' + psvar prompt = Prompt(powerline, side, theme, psvar, savedps) zsh.set_special_string(zpyvar, prompt) zsh.setvalue(psvar, '${' + zpyvar + '}')
def config_path(self): try: ret = zsh.getvalue('POWERLINE_CONFIG_PATHS') except IndexError: return None else: if isinstance(ret, (unicode, str, bytes)): return ret.split(type(ret)(':')) else: return ret
def set_prompt(powerline, psvar, side, theme, above=False): try: savedps = zsh.getvalue(psvar) except IndexError: savedps = None zpyvar = 'ZPYTHON_POWERLINE_' + psvar prompt = Prompt(powerline, side, theme, psvar, savedps, above) zsh.eval('unset ' + zpyvar) zsh.set_special_string(zpyvar, prompt) zsh.setvalue(psvar, '${' + zpyvar + '}') return ref(prompt)
def get_var_config(var): try: val = zsh.getvalue(var) if isinstance(val, dict): return mergeargs([parsedotval((u(k), u(v))) for k, v in val.items()]) elif isinstance(val, (unicode, str, bytes)): return mergeargs(parse_override_var(u(val))) else: return None except: return None
def config_path(self): try: ret = zsh.getvalue('POWERLINE_CONFIG_PATHS') except IndexError: return None else: if isinstance(ret, (unicode, str, bytes)): return [ path for path in ret.split(( b':' if isinstance(ret, bytes) else ':')) if path ] else: return ret
def config_path(self): try: ret = zsh.getvalue('POWERLINE_CONFIG_PATHS') except IndexError: return None else: if isinstance(ret, (unicode, str, bytes)): return [ path for path in ret.split((b':' if isinstance(ret, bytes) else ':')) if path ] else: return ret
def __str__(self): segment_info = { 'args': self.args, 'environ': environ, 'client_id': 1, 'local_theme': self.theme, 'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'), } r = self.powerline.render( width=zsh.columns(), side=self.side, segment_info=segment_info, ) if type(r) is not str: if type(r) is bytes: return r.decode('utf-8') else: return r.encode('utf-8') return r
def jobnum(self): zsh.eval('integer POWERLINE_JOBNUM=${(%):-%j}') return zsh.getvalue('POWERLINE_JOBNUM')
def get_var_config(var): try: return [parsedotval(i) for i in zsh.getvalue(var).items()] except: return None
def zsh_expand(s): zsh.eval('_POWERLINE_REPLY="' + s + '"') ret = zsh.getvalue('_POWERLINE_REPLY') zsh.setvalue('_POWERLINE_REPLY', None) return ret
def __contains__(key): try: zsh.getvalue(key) return True except IndexError: return False
def get(key, default=None): try: return string(zsh.getvalue(key)) except IndexError: return default
def set_prompt(powerline, psvar, side): savedps = zsh.getvalue(psvar) zpyvar = 'ZPYTHON_POWERLINE_' + psvar prompt = Prompt(powerline, side, psvar, savedps) zsh.set_special_string(zpyvar, prompt) zsh.setvalue(psvar, '${' + zpyvar + '}')
def set_prompt(powerline, psvar, side): savedps = zsh.getvalue(psvar) zpyvar = "ZPYTHON_POWERLINE_" + psvar prompt = Prompt(powerline, side, psvar, savedps) zsh.set_special_string(zpyvar, prompt) zsh.setvalue(psvar, "${" + zpyvar + "}")
def jobnum(self): zsh.eval('integer _POWERLINE_JOBNUM=${(%):-%j}') return zsh.getvalue('_POWERLINE_JOBNUM')
def config_path(self): try: return zsh.getvalue('POWERLINE_CONFIG_PATH') except IndexError: return None
def jobnum(self): return zsh.getvalue('_POWERLINE_JOBNUM')
def __getitem__(key): try: return string(zsh.getvalue(key)) except IndexError as e: raise KeyError(*e.args)