-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix bugs in _hydro_pwd #46
base: main
Are you sure you want to change the base?
Conversation
Also, it runs for every single prompt (or even twice per prompt?) instead of only when I would recommend not dealing with |
Just added here another commit that I've also been using for past 8 months. (see commit message for details) For me, these two commits fixed the small annoyances I had before. |
There were a couple of bugs in the implementation of _hydro_pwd which caused path to be rendered incorrectly: - if there is a parent directory named the same way as git root, it will be "highlighted" instead of the actual git root. For example, if you are in `/foo/repo/bar/repo/baz` and the second `repo` is git root, the first one will be highlighted. - if you are in directory named `:` (but not in git repo) it will not be shown. For example, if you are in `/tmp/:` you will see `/t/` instead of `/t/:`. - if one of your parent directories is `:` and you are in git repo, the name of the repo will be shown instead of `:`. For example, if you are in `/foo/:/bar/repo/baz` you will see `/f/repo/b/r/baz` instead of `/f/:/b/repo/baz`. - if `fish_prompt_pwd_dir_length` is set to `0` and one of the parent directories starts with dot, the directory shown will start with dot. For example, if you are in `/home/me/.config/fish` you will see `.fish` instead of `fish`. - if you are in a directory that looks like your home directory but isn't, it will be replaced with `~`. For example, if you are in `/tmp/home/me` you will see `/tmp~`.
These changes will make it so `_hydro_pwd` will run only when needed. Before this, `_hydro_pwd` would always run, not just when pwd changes beacuse of `--on-variable fish_prompt_pwd_dir_length`. Now the `hydro_pwd_dir_length` is used instead. The part about finding git root in `_hydro_pwd` we do want to run every time, so it is moved to `_hydro_prompt`. Otherwise things break when initializing and deleting git repos.
Hi. Why this is not yet merged? |
Since testing the code thoroughly would require significant effort and Hydro works well for me, I just haven't had the time to research this further. If you have the opportunity, we'd appreciate your feedback on this PR—even just to help add weight toward it being merged, hopefully soon. |
So, having To see this, you can add "echo hydro pwd!" in the beginning of _hydro_pwd. Currently, for me, it results in: hydro pwd!
~ ❯ hydro pwd!
~ ❯
hydro pwd!
~ ❯ hydro pwd!
~ ❯
hydro pwd!
~ ❯ hydro pwd!
~ ❯ cd Documents
hydro pwd!
hydro pwd!
hydro pwd!
~/Documents ❯ hydro pwd!
~/Documents ❯
hydro pwd!
~/Documents ❯ hydro pwd!
~/Documents ❯ ..
hydro pwd!
hydro pwd!
hydro pwd!
~ ❯ hydro pwd!
~ ❯ So it just runs twice per prompt for no reason and one more time when pwd is actually changed. If I then remove ~ ❯
~ ❯
~ ❯
~ ❯ cd Documents
hydro pwd!
~/Documents ❯
~/Documents ❯
~/Documents ❯
~/Documents ❯ ..
hydro pwd!
~ ❯
~ ❯
~ ❯ Which is what is expected. So I removed Except finding the git root is done in Since It is probably a good idea to make While I was figuring all this out, I also cleaned up how the pwd string is actually computed, because the current implementation is hacky and more complicated than it needs to be. The main issue I encountered with it is this bug from original PR comment:
To simplify this process of constructing the pwd string, I factored it into a These two changes should ideally have been separate commits (or PRs), but they are weirdly separated into two commits, because I was doing them in parallel. If you're interested, I can restructure commits in a way for them to make sense. |
There were a couple of bugs in the implementation of
_hydro_pwd
which caused path to be rendered incorrectly:if there is a parent directory named the same way as git root, it will be "highlighted" instead of the actual git root.
For example, if you are in
/foo/repo/bar/repo/baz
and the secondrepo
is git root, the first one will be highlighted.if you are in directory named
:
(but not in git repo) it will not be shown.For example, if you are in
/tmp/:
you will see/t/
instead of/t/:
.if one of your parent directories is
:
and you are in git repo, the name of the repo will be shown instead of:
.For example, if you are in
/foo/:/bar/repo/baz
you will see/f/repo/b/r/baz
instead of/f/:/b/repo/baz
.if
fish_prompt_pwd_dir_length
is set to0
and one of the parent directories starts with dot, the directory shown will start with dot.For example, if you are in
/home/me/.config/fish
you will see.fish
instead offish
.if you are in a directory that looks like your home directory but isn't, it will be replaced with
~
.For example, if you are in
/tmp/home/me
you will see/tmp~
.(Sorry I didn't make a commit per bug fix, probably would have been more readable that way)