Skip to content

Fix bug in sorin.fish theme - #2243

Closed
pickfire wants to merge 1 commit into
fish-shell:masterfrom
pickfire:master
Closed

pickfire wants to merge 1 commit into
fish-shell:masterfrom
pickfire:master

Conversation

@pickfire

Copy link
Copy Markdown
Contributor
  • Look for $TERM
  • Remove unknown line
  • Change email

@pickfire pickfire mentioned this pull request Jul 26, 2015
@faho

faho commented Aug 4, 2015

Copy link
Copy Markdown
Member

This is the wrong way. Apparently fish_config funcsaves fish_prompt after sourcing sorin.fish.

This means I've not been able to end up with a "%" fallback prompt, even after removing the login shell check and adding the missing "$".

I've moved the check into the fish_prompt function and it works - any reason you're not just doing that?

I.e:

function fish_prompt
        if test $TERM = "linux"
                echo -n "% ";
        else
                test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(hostname)' '

                test $USER = 'root'; and echo (set_color red)"#"

                # Main
                echo -n (set_color cyan)(prompt_pwd) (set_color red)'❯'(set_color yellow)'❯'(set_color green)'❯ '
        end
end

The right prompt is also not saved, but that's another issue.

@faho faho self-assigned this Aug 4, 2015
@faho

faho commented Aug 4, 2015

Copy link
Copy Markdown
Member

The right prompt is also not saved, but that's another issue.

More precisely, it's #736.

@pickfire

Copy link
Copy Markdown
Contributor Author

I just hope that it will not be re-run over and over again.

I think that I had forgotten to add support for root.

@faho

faho commented Aug 12, 2015

Copy link
Copy Markdown
Member

I just hope that it will not be re-run over and over again.

What do you mean? the TERM = Linux check? That's pretty much free - a single string comparison in a prompt function should be completely negligible.

I think that I had forgotten to add support for root.

No, that's in.

@pickfire

Copy link
Copy Markdown
Contributor Author

Are you going to change that TERM = Linux or am I going to do it?

@faho

faho commented Aug 15, 2015

Copy link
Copy Markdown
Member

It's your work - I was waiting for you to do it.

I'd also like it better if you put the check into the function directly instead of doing that other dance.

@pickfire

Copy link
Copy Markdown
Contributor Author

Check?

@faho

faho commented Aug 15, 2015

Copy link
Copy Markdown
Member

Like I've written here - do that workaround for "Linux" terms in the fish_prompt function instead of defining a different version of that function.

@pickfire

Copy link
Copy Markdown
Contributor Author

Well I have tested the following in my computer and it works, should I use that instead as it is working and I think it is better not to put the code in the fish_prompt:

test $TERM = 'linux'; and function fish_prompt; echo -n '% '; end

I found out that I cannot use arrow keys in linux framebuffer, it shows up OA - OD, it this a feature?

You can actually add color to code by adding ```fish.

@faho

faho commented Aug 16, 2015

Copy link
Copy Markdown
Member

That actually shouldn't work as you are missing the "$".

I think it is better not to put the code in the fish_prompt

Why? Have you actually gotten the fallback prompt this way?

You can actually add color to code by adding ```fish.

Neat.

@pickfire

Copy link
Copy Markdown
Contributor Author

Sorry, that is a typo error, adding $ did work. I have updated it. Thanks.

So, is it okay to leave it that way? As it is simpler.

@faho

faho commented Aug 16, 2015

Copy link
Copy Markdown
Member

Where have you updated it? I'm not seeing a new commit.

So, is it okay to leave it that way? As it is simpler.

I don't believe it's simpler and I have not been able to actually get it to work - i.e. getting a fallback "%" prompt.

@faho faho closed this in b615534 Aug 16, 2015
@faho

faho commented Aug 16, 2015

Copy link
Copy Markdown
Member

Okay, I tested it again (with a fixed "$TERM"), and here's the issue with your approach:

  • It actually defines "fish_prompt" based on the "TERM" value of the term that fish_config is started in
  • It defines it, and then re-defines it again with the non-fallback value, which will then be used (this means that it is not possible to get the fallback prompt, even if you start it with $TERM set to "linux")
  • It defines it once, which means if you switch between xterm/konsole/gnome-terminal or whatever and the kernel-vt-thing (TERM="linux"), you'll get one prompt for both - either the ugly fallback, or the incorrectly displayed real prompt on the 8-color VT

What I've done now is remove the fallback completely, since the fallback displays no info whatsoever while the real prompt will look wrong but still work for the most part. This is also the only prompt with such a fallback.

If you want such a fallback, there's probably a better and more consistent way to do it.

@pickfire

Copy link
Copy Markdown
Contributor Author

I found out that I cannot use arrow keys in linux framebuffer, it shows up OA - OD, it this a feature?

What about that?

@faho

faho commented Aug 17, 2015

Copy link
Copy Markdown
Member

I have no idea - it works for me (always has).

Anyway, it's a different bug and has nothing to do with this prompt.

faho added a commit to faho/fish-shell that referenced this pull request Sep 8, 2015
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants