santagada / xontrib-powerline

Powerline for Xonsh shell
MIT License
49 stars 20 forks source link

error at entering a git project directory #8

Closed sejktmcsdlmfhsc closed 7 years ago

sejktmcsdlmfhsc commented 7 years ago

hi @santagada, I quite like your xontrib!! (..and look forward to configure it's styling on my machine ) unfortunately it throws an error as soon as I enter a git project directory (and looses the bottom toolbar):

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/amnesia/.local/lib/python3.4/site-packages/xonsh/prompt/__amalgam__.py", line 636, in __call__
    prompt = self._format_prompt(template=template)
  File "/home/amnesia/.local/lib/python3.4/site-packages/xonsh/prompt/__amalgam__.py", line 644, in _format_prompt
    template = template() if callable(template) else template
  File "/home/amnesia/.local/lib/python3.4/site-packages/xontrib/powerline.xsh", line 131, in prompt
    r = s()
  File "/home/amnesia/.local/lib/python3.4/site-packages/xontrib/powerline.xsh", line 46, in cwd
    ps[git_idx] = '{BLUE}' + ps[git_idx] + '{WHITE}'
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/amnesia/.local/lib/python3.4/site-packages/xonsh/prompt/__amalgam__.py", line 729, in _failover_template_format
    return template()
  File "/home/amnesia/.local/lib/python3.4/site-packages/xontrib/powerline.xsh", line 131, in prompt
    r = s()
  File "/home/amnesia/.local/lib/python3.4/site-packages/xontrib/powerline.xsh", line 46, in cwd
    ps[git_idx] = '{BLUE}' + ps[git_idx] + '{WHITE}'
IndexError: list index out of range

the $PWD in this example is: '/home/amnesia/.local/lib/python3.4/site-packages/xonsh' not sure, what is happening there - any ideas? thank you so much! best, sej

my xonfig is:

+------------------+---------------------+
| xonsh            | 0.5.8               |
| Git SHA          | e7a9bcf             |
| Commit Date      | Mar 6 23:45:51 2017 |
| Python           | 3.4.2               |
| PLY              | 3.9                 |
| have readline    | True                |
| prompt toolkit   | 1.0.13              |
| shell type       | prompt_toolkit      |
| pygments         | 2.2.0               |
| on posix         | True                |
| on linux         | True                |
| distro           | debian              |
| on darwin        | False               |
| on windows       | False               |
| on cygwin        | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |
+------------------+---------------------+
santagada commented 7 years ago

can you give me the result of: git rev-parse --show-toplevel and the value of $HOME?

With those two values + $PWD I can reproduce your issue.

sejktmcsdlmfhsc commented 7 years ago

sure: $HOME : '/home/amnesia' git rev-parse --show-toplevel : /live/persistence/TailsData_unlocked/Persistent/Install/xonsh_offline/xonsh $PWD : '/home/amnesia/.local/lib/python3.4/site-packages/xonsh'

..and now it becomes more clear: $PWD actually starts with $HOME, but top_level does not. so idx looks at the shortened cwd and fails with it's too high index.

the reasons for this strange assembly of paths are:

sejktmcsdlmfhsc commented 7 years ago

..now I found a more regular directory - there it works fine: scr

santagada commented 7 years ago

quite an edge case indeed, but it should be supported, let me see if I can fix it on v0.3.2. What I will do is do matching right to left instead of left to right (which makes sense because at any point it can be a link).

Thanks this will make the code better :)

santagada commented 7 years ago

@sejktmcsdlmfhsc by the way you need to correct the size of the powerline symbols in your terminal to make it look really awesome. I think you need the powerline symbols to be 1pt or so bigger.

santagada commented 7 years ago

xontrib-powerline v0.3.2 should have fixed this, please test if you can.

sejktmcsdlmfhsc commented 7 years ago

@santagada works like charm - thanks a lot!! now I can start customizing it.. yes, there is something wrong with the powerline setup on this machine, I already tried de/increasing font size, unfortunately that did not help - maybe I should try another patched font..

santagada commented 7 years ago

I use http://nerdfonts.com/, they are heavy but awesome in that it has all the icons you could possibly need.

sejktmcsdlmfhsc commented 7 years ago

@santagada Thank you so much for the link - these NerdFonts are truely awesome!! Unfortunately they did not fix the display issue gap in my left facing arrows. I have have to check if this maybe is a gnome-terminal problem.