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

Show path relative to repo #349

Closed
felixSchl opened this issue Mar 3, 2015 · 6 comments · Fixed by #648
Closed

Show path relative to repo #349

felixSchl opened this issue Mar 3, 2015 · 6 comments · Fixed by #648
Assignees
Labels
enhancement Feature request git Related to Git VCS data
Milestone

Comments

@felixSchl
Copy link
Contributor

It would be nice if I could display the path in my prompt relative to the git repository I am working on. This removes all the unnecessary parts of the path and leaves me to focus on the repo itself. Is this functionality already available, and if not is it something worthwhile looking into?

Furthermore, would it be possible to know if we are inside a submodule? So we could show the housing git repo's name somewhere as well? This would be a recursive op, so the displayed level of parent repos would need to be controlled.

@dolmen
Copy link
Collaborator

dolmen commented Mar 11, 2015

It would be nice if I could display the path in my prompt relative to the git repository I am working on. This removes all the unnecessary parts of the path and leaves me to focus on the repo itself. Is this functionality already available, and if not is it something worthwhile looking into?

No and yes.

Furthermore, would it be possible to know if we are inside a submodule?

Yes it is probably possible. Is it sane to look into this when displaying the prompt? No. Too much runtime cost. That would impact 99% of liquidprompt users that use git repo without submodules.

@dolmen dolmen added enhancement Feature request git Related to Git VCS data labels Mar 11, 2015
@paulvt
Copy link

paulvt commented Jun 28, 2015

Or just color the part of the prompt that is relative to the base of the VCS. At one time I used some code that printed it like this: ~/projects/some-repo[master]/sub/dir. However, given the different approach of liquidprompt (only append things when needed) and features such as part shortening, this might not work.

@rhopfer
Copy link

rhopfer commented Aug 14, 2016

Sorry for the advertisement, but maybe you are interested how I do this in my prompt. I use an environment variable PROMPT_BASES to store special paths which should be reduced to a name. It should be easy to adopt this to your prompt.

@nojhan
Copy link
Collaborator

nojhan commented Sep 17, 2016

I like the idea, but it conflicts with features related to the path management (shortening, for instance). I think the idea of @paulvt feels more ergonomic: just highlight the part of the path that is under to the current repository root (the part that is shown). The prompt of @rhopfer makes me realize that we can also color the slashes.

@felixSchl
Copy link
Contributor Author

I'd be happy to put in the hours to support both. I know I have not properly addressed the issue of path shortening (I listed it in the TODOs of my PR), but I would assume it should simply shorten the shortened (relative to repo) path. Either way, I have been using this at work for the last week and it's been really nice to use. I made a quite asciinema demo to demonstrate it: https://asciinema.org/a/21be5t92ib26uddrs9ehuaovr.

@nojhan nojhan self-assigned this Aug 19, 2018
@Rycieos Rycieos added this to the v2.0 milestone Jul 5, 2020
@Rycieos Rycieos assigned Rycieos and unassigned nojhan Jan 15, 2021
@Rycieos Rycieos linked a pull request Jan 21, 2021 that will close this issue
@Rycieos
Copy link
Collaborator

Rycieos commented Jan 30, 2021

This was (partially) implemented as part of v2.0.0-rc.1.

By default, the VCS repo root is highlighted and never shortened, no matter which path shortening method is selected (can be disabled with LP_PATH_VCS_ROOT).

However, none of the current path shortening methods remove all of the path before the repo root (relative to repo root). As I mentioned in #465 (comment), I am open to a new path shortening method that shows relative to the repo root, if someone wants to make a PR on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request git Related to Git VCS data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants