Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alt-left/right overwrites fish_prompt without clearing trailing characters #3550

Closed
artagnon opened this issue Nov 14, 2016 · 9 comments
Closed
Labels
bug Something that's not working as intended
Milestone

Comments

@artagnon
Copy link

I have a simple prompt:

function fish_prompt
	set_color yellow
	echo (pwd) | sed -e "s|^$HOME|~|" -e "s|^/sandbox/rramacha|\$s|"
	set_color normal
	echo '$ '
end

When I alt-left from ~/src/llvm/tools/polly/test/ScopDetect to ~/src/jsoncpp, my prompt is mangled:

~/src/jsoncppols/polly/test/ScopDetect
$

Not sure how to work around this except by padding the path with trailing spaces?

@faho
Copy link
Member

faho commented Nov 14, 2016

This seems related to #3537, since it also only seems to occur with a multi-line prompt.

@faho faho added the bug Something that's not working as intended label Nov 14, 2016
@faho faho added this to the fish 2.5.0 milestone Nov 14, 2016
@artagnon
Copy link
Author

I looked at the that thread earlier, but it didn't strike me as being related. This is probably a dupe, and the most elegant workaround is a single-line prompt.

@artagnon
Copy link
Author

Can I change the color of the prompt twice on the same line? I want to distinguish between the cwd path and '$'.

@krader1961
Copy link
Contributor

Yes, you can change colors multiple times. I do it:

screen shot 2016-11-14 at 12 06 46

@artagnon
Copy link
Author

Hm, I added -n to my echo invocations, but it seems to have no effect.

@krader1961
Copy link
Contributor

Works for me:

function fish_prompt
    set -l cwd (echo (pwd) | sed -e "s|^$HOME|~|" -e "s|^/sandbox/rramacha|\$s|")
    echo -n (set_color yellow)$cwd(set_color normal) '$ '
end

Note that mutating the PWD can be done more efficiently but I'll leave that as an exercise for the student. Hint: start by using $PWD rather than (pwd) and use the string builtin rather than shelling out to sed.

@artagnon
Copy link
Author

Thanks! Much appreciated.

@zanchey zanchey modified the milestones: fish-future, fish 2.5.0 Jan 11, 2017
@faho
Copy link
Member

faho commented Dec 13, 2020

Can't reproduce in master, there've been a lot of changes since this was reported. Closing!

@faho faho closed this as completed Dec 13, 2020
@faho faho removed this from the fish-future milestone Dec 13, 2020
@zanchey
Copy link
Member

zanchey commented Dec 27, 2020

It's broken in 3.1.2 but fixed in 3.2.0.

@zanchey zanchey added this to the fish 3.2.0 milestone Dec 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants