Skip to content

Starship - Prompt is mangled #1005

Closed
Closed

Description

@igneousflock

Describe the bug

When using nu compiled with starship prompt support, the prompt appears mangled. See screenshot.

%{%}~%{%} 
%{%}->%{%} cd aur-build/nushell/

%{%}nushell%{%} on %{%} %{%}%{%}master%{%} is %{%}📦 %{%}%{%}v0.5.1%{%} via %{%}🦀 %{%}%{%}v1.39.0%{%} 
%{%}->%{%}

The syntax highlighting appears to work though.

To Reproduce

Steps to reproduce the behavior:

  1. cargo install --path . --features starship-prompt --force
  2. nu

The problem appears with both alacritty and kitty. It occurs when nu is started from zsh or bash.

Expected behavior

The prompt should appear as normal.

Screenshots

2019-11-23-224716

Configuration

  • OS: Arch Linux
  • Version Kernel 5.3.12
  • Rust:
# cargo --version && rustc --version
cargo 1.39.0 (1c6ec66d5 2019-09-30)
rustc 1.39.0 (4560ea788 2019-11-04)
  • Terminal: Kitty v0.14.6 or Alacritty fork v0.3.3
  • Optional features: starship-prompt

Activity

  1. sophiajt commented on Nov 24, 2019

    @sophiajt
    Contributor

    I don't think this will fix it, but do you get the same behavior with cargo install --path . --force --all-features?

  2. igneousflock commented on Nov 24, 2019

    @igneousflock
    ContributorAuthor

    Same behavior, unfortunately.

  3. sophiajt commented on Nov 25, 2019

    @sophiajt
    Contributor

    I'm trying to figure out what might be causing it. I'm able to run Kitty and Nu together with Nu as my main shell (though I needed to tweak Kitty a tiny bit to allow it):

    Screenshot from 2019-11-25 17-07-07

    Let me also try running via bash

  4. sophiajt commented on Nov 25, 2019

    @sophiajt
    Contributor

    Hmm, I'm also seeing it work correctly in Kitty with bash + nu:

    Screenshot from 2019-11-25 17-11-10

    Trying to think what might be different. I'm using the default fonts on pop! OS: Fira Mono Regular.

    If you run through something like GNOME terminal with the default color scheme, do you get the same behavior? I'm wondering if we can isolate if it's the color scheme, the terminal, the font, or something else.

  5. igneousflock commented on Nov 25, 2019

    @igneousflock
    ContributorAuthor

    I was using Fira Code font with ligatures

    • Disabling ligatures does not help (in Kitty or Alacritty)
    • Switching to Fira Mono or DejaVu does not help (in Kitty or Alacritty)
    • Switching to upstream alacritty (whatever Arch has) does not help
    • Using GNOME Terminal out-of-the-box does not help
    • Switching the colorscheme in Kitty does not help (I was using this)

    I am using starship in zsh and it works great. I'm stumped as to what else could be different. I am on the latest master, fe53c37, still built with all features.

  6. sphinxc0re commented on Nov 27, 2019

    @sphinxc0re

    Same problem here. Usually using zsh with starship prompt.

  7. mgattozzi commented on Nov 27, 2019

    @mgattozzi

    I did some manual testing on osx

    • Every terminal (alacritty, iterm2, builtin) was mangled if nu was run from the command line.
    • exec nu where it should have replaced the zsh process did nothing
    • Every terminal works with nushell if you put it in /etc/shells and then chsh your user to it

    What this makes me understand is that unless it's your default shell it fails to produce non garbled output. I don't know exactly what does it, but zsh requires one to add eval "$(starship init zsh)" in order for it to be used as the prompt. Maybe something isn't being set if nushell runs as a subprocess.

  8. mgattozzi commented on Nov 27, 2019

    @mgattozzi

    Some followup testing this is messed up from a zsh shell that isn't using starship as well.

  9. tchak commented on Nov 27, 2019

    @tchak
    Contributor

    Mine looks like this:
    Screenshot 2019-11-27 at 22 57 29

    I am assuming it's the same problem?

  10. Avi-D-coder commented on Nov 28, 2019

    @Avi-D-coder

    This makes nu unusable for me.

  11. sophiajt commented on Nov 28, 2019

    @sophiajt
    Contributor

    @Avi-D-coder - you can use Nu without this feature enabled. If you do cargo install nu it will give you the non-starship prompt

  12. sophiajt commented on Nov 28, 2019

    @sophiajt
    Contributor

    In case anyone wants to help figure it out, these are the configurations I've tried:

    Ubuntu/Pop! OS:

    • Install zsh, chsh to zsh
    • gnome-terminal:
      • Using Fira Mono Regular
      • Run nu from inside zsh (works)
    • alacritty-fork mentioned in issue:
      • Run nu from inside zsh (works)
    • kitty 9.0.0
      • Run nu form inside zsh (works)

    macOS 10.15.1 (default font):

    • default terminal
      • run nu from inside zsh (works)
    • iTerm2
      • run nu from inside zsh (works)
  13. sophiajt commented on Nov 28, 2019

    @sophiajt
    Contributor

    @avandesa - Can you also post the font, starship config, and alacritty config?

    I'm trying to think of other ways the systems might be different, or ways I could repro short of building an arch linux image.

  14. igneousflock commented on Nov 28, 2019

    @igneousflock
    ContributorAuthor

    Here are my configurations:

    $  cat ~/.config/kitty/{kitty,theme}.conf
    include ./theme.conf
    
    font_family			Fira Code
    bold_font			auto
    italic_font			auto
    bold_italic_font	auto
    background #001e26
    foreground #708183
    cursor #708183
    selection_background #002731
    color0 #002731
    color8 #001e26
    color1 #d01b24
    color9 #bd3612
    color2 #728905
    color10 #465a61
    color3 #a57705
    color11 #52676f
    color4 #2075c7
    color12 #708183
    color5 #c61b6e
    color13 #5856b9
    color6 #259185
    color14 #81908f
    color7 #e9e2cb
    color15 #fcf4dc
    selection_foreground #001e26
    

    alacritty.yml

    $ cat ~/.config/starship.toml
    [character]
    symbol = "->"
    
    [package]
    #symbol = "V "
    
    [rust]
    #symbol = "𝗥 "
    
    $ cat /etc/fonts/fonts.conf
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <!-- /etc/fonts/fonts.conf file to configure system font access -->
    <fontconfig>
    	<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
    		<its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
    	</its:rules>
    
    	<description>Default configuration file</description>
    
    <!-- Font directory list -->
    
    	<dir>/usr/share/fonts</dir>
    	<dir>/usr/local/share/fonts</dir>
    	<dir prefix="xdg">fonts</dir>
    	<!-- the following element will be removed in the future -->
    	<dir>~/.fonts</dir>
    
    <!--
      Accept deprecated 'mono' alias, replacing it with 'monospace'
    -->
    	<match target="pattern">
    		<test qual="any" name="family">
    			<string>mono</string>
    		</test>
    		<edit name="family" mode="assign" binding="same">
    			<string>monospace</string>
    		</edit>
    	</match>
    
    <!--
      Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
    -->
    	<match target="pattern">
    		<test qual="any" name="family">
    			<string>sans serif</string>
    		</test>
    		<edit name="family" mode="assign" binding="same">
    			<string>sans-serif</string>
    		</edit>
    	</match>
    
    <!--
      Accept deprecated 'sans' alias, replacing it with 'sans-serif'
    -->
    	<match target="pattern">
    		<test qual="any" name="family">
    			<string>sans</string>
    		</test>
    		<edit name="family" mode="assign" binding="same">
    			<string>sans-serif</string>
    		</edit>
    	</match>
    <!--
      Accept alternate 'system ui' spelling, replacing it with 'system-ui'
    -->
    	<match target="pattern">
    		<test qual="any" name="family">
    			<string>system ui</string>
    		</test>
    		<edit name="family" mode="assign" binding="same">
    			<string>system-ui</string>
    		</edit>
    	</match>
    
    <!--
      Load local system customization file
    -->
    	<include ignore_missing="yes">conf.d</include>
    
    <!-- Font cache directory list -->
    
    	<cachedir>/var/cache/fontconfig</cachedir>
    	<cachedir prefix="xdg">fontconfig</cachedir>
    	<!-- the following element will be removed in the future -->
    	<cachedir>~/.fontconfig</cachedir>
    
    	<config>
    <!--
      Rescan configuration every 30 seconds when FcFontSetList is called
     -->
    		<rescan>
    			<int>30</int>
    		</rescan>
    	</config>
    
    </fontconfig>
  15. jeffhertzler commented on Nov 28, 2019

    @jeffhertzler

    I was seeing the same issue when I ran nu from zsh. What fixed it for me was disabling starship (commenting out the init line # eval "$(starship init zsh)") in zsh before running nu.

  16. igneousflock commented on Nov 28, 2019

    @igneousflock
    ContributorAuthor

    I can confirm what @mgattozzi said; If i chsh -s $(which nu), everything works great. What's also interesting is if I launch a terminal with nu as the shell, launch zsh from that, then launch nu again, the prompt is broken. If I do what @jeffhertzler just said, the prompt works.

    • nu works
    • bash -> nu works
    • zsh -> nu does not work
    • nu -> zsh -> nu does not work
    • nu -> bash -> nu works
    • zsh w/o starship -> nu works

    So it sounds like it's an issue of the starship init zsh script being run before initializing nu. It's probably not an issue of system configuration.

  17. tchak commented on Nov 28, 2019

    @tchak
    Contributor

    In my case I start nu from bash on MacOS. I tried to remove eval "$(starship init bash)" from my .bash_profile – it changes nothing.

  18. thegedge commented on Nov 29, 2019

    @thegedge
    Contributor

    For those having issues, if you unset the STARSHIP_SHELL environment variable when running nushell (for example, STARSHIP_SHELL="" nu), do you still have the same issue?

  19. tchak commented on Nov 29, 2019

    @tchak
    Contributor

    @thegedge it makes no difference for me

  20. sophiajt commented on Nov 29, 2019

    @sophiajt
    Contributor

    I just landed a possible fix for this (#1029). For folks who are having this issue, can you try the latest master?

    Once you check it out, you can build and run it with:

    cargo build --all-features && cargo run --all-features
    
  21. tchak commented on Nov 29, 2019

    @tchak
    Contributor

    works for me

  22. mgattozzi commented on Nov 30, 2019

    @mgattozzi

    Confirms this works for me!

  23. igneousflock commented on Nov 30, 2019

    @igneousflock
    ContributorAuthor

    The fix works. I'll be closing this issue since it appears to be resolved.

    Thanks so much for your help @jonathandturner!

  24. Avi-D-coder commented on Sep 6, 2020

    @Avi-D-coder

    This is broken again.
    I have to use unset STARSHIP_SHELL && nu so the prompt does not get mangled.

  25. CBenoit commented on Oct 26, 2020

    @CBenoit
    Contributor

    I have the same issue on master built and installed using

    cargo install --features=extra --path .

    Commit is 1b0ed30

    image

    By running unset STARSHIP_SHELL && nu there is no issue.

    image

    I'm not sure if the issue comes from nu or starship though. I'm running nu from my zsh shell that is already using starship as prompt.

  26. ibraheemdev commented on Nov 13, 2020

    @ibraheemdev

    I'm having the same issue using nu as my login shell

  27. rrichardson commented on Nov 25, 2020

    @rrichardson
    Contributor

    Following the lead from @CBenoit 's comment. This works and is a bit more ergonomic.
    In your ~/.config/nu/config.toml

    prompt = "echo $(STARSHIP_SHELL= starship prompt)"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions