anki-code / xontrib-prompt-bar

The bar prompt for xonsh shell with customizable sections and Starship support.
BSD 2-Clause "Simplified" License
49 stars 2 forks source link

Add gitstatus to the right side #3

Closed dakota-marshall closed 1 year ago

dakota-marshall commented 2 years ago

Installed prompt_bar via proper methods, when running I get the following:

$ xontrib load prompt_bar

prompt: error: on field 'prompt_bar'
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
TypeError: expected string or bytes-like object
{ERROR:prompt_bar}
{ERROR:prompt_bar}
@

Running with traceback enabled gives:

prompt: error: on field 'prompt_bar'
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/xonsh/prompt/__amalgam__.py", line 189, in _get_field_value
    return self.fields.pick(field)
  File "/usr/lib/python3.10/site-packages/xonsh/prompt/__amalgam__.py", line 434, in pick
    value = value()
  File "/usr/lib/python3.10/site-packages/xontrib/prompt_bar.py", line 153, in _prompt_bar
    rpc = _format_sections(_RIGHT)
  File "/usr/lib/python3.10/site-packages/xontrib/prompt_bar.py", line 121, in _format_sections
    map[key] = _wrappers[wrapper](map[key])
  File "/usr/lib/python3.10/site-packages/xontrib/prompt_bar.py", line 90, in <lambda>
    'nocolorx': lambda v: _remove_colors(v),
  File "/usr/lib/python3.10/site-packages/xontrib/prompt_bar.py", line 42, in _remove_colors
    return re.sub('{([A-Z0-9#_]+?)}', '', s)
  File "/usr/lib/python3.10/re.py", line 209, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
{ERROR:prompt_bar}
@

Im not sure what exactly is breaking. Let me know if there is anything else I can provide to help with the issue

anki-code commented 2 years ago

Hi! Yeah, this was appeared after the new xonsh release. I've made 0.4.2 with temporary fix.

anki-code commented 2 years ago

@jnoortheen Hi! After new implementation of gitstatus this is not working and commented:

https://github.com/anki-code/xontrib-prompt-bar/blob/29469a171ac51c26d23ae2d131758a4511fae97a/xontrib/prompt_bar.py#L15

What is the best way to get gitstatus now? Thanks!

jnoortheen commented 2 years ago

@anki-code you can use similar approach here https://github.com/jnoortheen/xontrib-powerline3/blob/715d42d625db76dfceb6b3d59ec99668831a1df3/xontrib_powerline3/fields.py#L193 gettimg the whole value at once will also work

anki-code commented 1 year ago

Fixed in 0.5.5