oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.44k stars 222 forks source link

Fix pwd calculation for git worktrees #345

Closed tommyknows closed 1 year ago

tommyknows commented 1 year ago

A refactor changed this block from a set git_dir $PWD to set git_dir $real_pwd, but as real_pwd is a "static" variable and not dynamically computed, this breaks within the pushd / popd flow.

Instead of using $real_pwd, we need to compute the current directory by calling __bobthefish_pwd again.

Fixes #249.


btw, I'm not 100% certain about this worktree-support anyways. For me, it doesn't "work", or rather, I'm using worktrees but the normal git-prompt works fine.

My use-case is different from what was described in the original issue for worktrees, and have the following directory structure:

$ git worktree list
/tmp/repo/main                     562496718 [main]
/tmp/repo/branch123                2fc53b215 [branch123]
/tmp/repo/another-branch           5615bf3bb [another-branch]

but the .git repo is in tmp/repo/main/.git.

So my current git-prompts look like this:

/p/t/r/branch123 || branch123 || 

Meaning the branch is shown twice, once in the git-info and once in the path, while I have no idea in what project I'm in :)

In my case, I'd rather have the left part of the prompt show me the project, with the "branch directory" trimmed away, as that's show in the git-info already.

I don't think there's a generic solution to how people use worktrees, at least I can't see a common theme between #29 and my use-case, so I might have a look at making this functionality customisable somehow, although I'm not quite sure yet how to do that :)

Thanks a lot for this great theme & prompt!

bobthecow commented 1 year ago

Good catch, and thanks for the fix!

To be honest, I don't use git worktrees at all, so I'm looking to contributors for input on how exactly it should function. If there's a way to support the original use case and yours as well, especially in a more bobthefishy way, I'm open to suggestions :)

tommyknows commented 1 year ago

Not sure, I've got a working version that enables my use-case, but it's probably super brittle in all other use-cases 😄

I might spend some more time on the weekend to check if it can be generalised...