hydro
hydro copied to clipboard
Fix bugs in _hydro_pwd
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)
Also, it runs for every single prompt (or even twice per prompt?) instead of only when $PWD
is changing. This is caused by --on-variable fish_prompt_pwd_dir_length
. I know the standard prompt_pwd
is setting the $fish_prompt_pwd_dir_length
, and there is probably something else in fish that sets it.
I would recommend not dealing with $fish_prompt_pwd_dir_length
and instead have something like $hydro_pwd_dir_length