Giter Site home page Giter Site logo

set_color creates extra space about fish-shell HOT 8 CLOSED

rackodo avatar rackodo commented on September 25, 2024
set_color creates extra space

from fish-shell.

Comments (8)

zanchey avatar zanchey commented on September 25, 2024

Excitingly, this does not happen in git main at 4c1e25b, but the set_color invocation does not work quite right (eg echo What color is the date\? (set_color yellow; date +%T; set_color blue) has a blue date, not a yellow one).

from fish-shell.

rackodo avatar rackodo commented on September 25, 2024

Weird... that's not what happens for me.

Screenshot 2023-12-31 at 2 38 02 pm

For reference, here's my fish_greeting.fish file.

function fish_greeting
    echo Hello friend!
    echo The time is (set_color yellow; date +%T; set_color blue) and this machine is called $hostname
end

(I know the text doesn't look blue, but that's what blue is in my palette.)

from fish-shell.

zanchey avatar zanchey commented on September 25, 2024

Sorry, I see the behaviour you describe, but only on 3.6.4 and not in main, where it is different but also wrong.

from fish-shell.

rackodo avatar rackodo commented on September 25, 2024

Is 3.6.4 not the latest release...? I tried upgrading fish (using Homebrew) but 3.6.4 is the latest version available. Or is main not the same?

from fish-shell.

zanchey avatar zanchey commented on September 25, 2024

3.6.4 is the most recent release, but main includes a substantial port of the internals of fish, which has fixed some longstanding bugs but also introduced new ones.

from fish-shell.

krobelus avatar krobelus commented on September 25, 2024

the color change bisects to ce559bc (cc @mqudsi)

from fish-shell.

krobelus avatar krobelus commented on September 25, 2024

I've fixed the color.

The extra space happens because

$ echo (echo 1; set_color blue) 2

is equivalent(*) to

$ echo (echo 1; echo -n \e\[34m) 2

or

$ echo (echo 1\n\e\[34m) 2

fish trims trailing newlines from command substitution output.
There is no trailing newline here. echo will print both lines separated by a space. The second line is empty.

We could try to remove the last \n if it's followed by only invisible character sequences but that sounds confusing.
Probably best to work around it on your end

(*) found with

$ set_color blue | string escape
\e\[34m⏎

from fish-shell.

zanchey avatar zanchey commented on September 25, 2024

Possibly we should fix the tutorial, but it's inelegant. echo The time is (set_color yellow)(date +%T)(set_color normal) now is the best I can do, but runs into our old friend Cartesian expansion if set_color produces no output.

from fish-shell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.