Skip to content

Match the whole real home directory in prompt_pwd. - #2283

Merged
faho merged 1 commit into
fish-shell:masterfrom
treeman:prompt_pwd
Aug 14, 2015
Merged

faho merged 1 commit into
fish-shell:masterfrom
treeman:prompt_pwd

Conversation

@treeman

@treeman treeman commented Aug 8, 2015

Copy link
Copy Markdown
Contributor

This fixes a bug where only the prefix of the home directory is matched.

Current behavior:

tree@thewall ~-old> pwd
/home/tree-old
tree@thewall ~/test> pwd
/home/tree-old/test

And the fixed behavior:

tree@thewall /h/tree-old> pwd
/home/tree-old
tree@thewall /h/t/test> pwd
/home/tree-old/test

@lledey

lledey commented Aug 8, 2015

Copy link
Copy Markdown
Contributor

I believe the intended behavior is

tree@thewall ~> pwd
/home/tree-old
tree@thewall ~/test> pwd
/home/tree-old/test

I think the problem is in the sed call trying to interpret the dash in $realhome. (I found this)

@faho

faho commented Aug 8, 2015

Copy link
Copy Markdown
Member

I think the problem is in the sed call trying to interpret the dash in $realhome. (I found this)

I don't think so - a "-" only has special meaning inside "[" and "]" when it's not on the first position.

You can also reproduce the issue if you make a directory named "$HOMEtest" i.e. something like "/home/treetest". That also goes wrong because the original expression only looks for $HOME at the beginning of the string, not that it's actually referring to the actual $HOME directory.

@treeman

treeman commented Aug 8, 2015

Copy link
Copy Markdown
Contributor Author

As noted in the comments, the old did never substitute. Managed with two expressions, not sure how to only use one?

@lledey I don't think that's right? Now it should only match the correct home directory and substitute.

Now actually substitutes correctly:

tree@thewall ~> pwd
/home/tree
tree@thewall ~/test> pwd
/home/tree/test
tree@thewall /h/tree-old> pwd
/home/tree-old
tree@thewall /h/t/test> pwd
/home/tree-old/test

@lledey

lledey commented Aug 8, 2015

Copy link
Copy Markdown
Contributor

Ooooh, you're right, I didn't understand the problem well, sorry

@faho

faho commented Aug 14, 2015

Copy link
Copy Markdown
Member

This works and I can't figure out how to do it in one expression - I can't get a character group that means "/ or end of line".

So I'm merging this. Thanks for your contribution!

faho added a commit that referenced this pull request Aug 14, 2015
Match the whole real home directory in prompt_pwd.
@faho
faho merged commit 81696c1 into fish-shell:master Aug 14, 2015
@zanchey zanchey added this to the next-2.x milestone Nov 4, 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.

4 participants