oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.46k stars 227 forks source link

Problems with no default Python #335

Closed henryiii closed 8 months ago

henryiii commented 2 years ago

The theme isn't happy if there's no default python (like on macOS in my case):

fish: Unknown command: python
~/.config/fish/functions/fish_prompt.fish (line 1): 
python --version 2>&1 | tr '\n' ' '
^
in command substitution
        called on line 850 of file ~/.config/fish/functions/fish_prompt.fish
in function '__bobthefish_virtualenv_python_version'
        called on line 1 of file ~/.config/fish/functions/fish_prompt.fish
in command substitution
        called on line 866 of file ~/.config/fish/functions/fish_prompt.fish
in function '__bobthefish_prompt_virtualfish'
in function 'iterm2_fish_prompt'
in command substitution
in command substitution
in function '__fish_prompt_orig'
        called on line 47 of file -
in function 'fish_prompt'
in command substitution
~/.config/fish/functions/fish_prompt.fish (line 850): Unknown command
    switch (python --version 2>&1 | tr '\n' ' ')
           ^
in function '__bobthefish_virtualenv_python_version'
        called on line 1 of file ~/.config/fish/functions/fish_prompt.fish
in command substitution
        called on line 866 of file ~/.config/fish/functions/fish_prompt.fish
in function '__bobthefish_prompt_virtualfish'
in function 'iterm2_fish_prompt'
in command substitution
in command substitution
in function '__fish_prompt_orig'
        called on line 47 of file -
in function 'fish_prompt'
in command substitution

For some reason, this only happens in the VSCode terminal; other terminals are fine. I'm guessing this could be switching based on an envvar or something VSCode sets and not on whether python is available? A little extra protection for the existence of the python command would be nice. Also, python is required to be available via PEP 394, only python3 is required.

FYI, I also have pyenv installed, which loves to break things by adding shims, but I don't think that's visible or causing a problem here. PPS: I think vscode is getting tripped up on conda, possibly. It does seem to happen only if I start vscode from a shell with a conda environment activated. Either way, it's still shouldn't make the terminal dump a page of text trying to print the prompt if python is missing. :)