-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Obey GIT_DIR if set for vcsh compatability #43
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
Conversation
You'll also need to change this line: typeset -gH _P9K_NEXT_VCS_DIR=$PWD To this: typeset -gH _P9K_NEXT_VCS_DIR=${GIT_DIR:-$PWD} |
There are a few more lines that need to be changed. Here's a diff that worked for me. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 48c393b..d750626 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1648,7 +1648,7 @@ function _p9k_vcs_style() {
function _p9k_vcs_render() {
if [[ -v _P9K_NEXT_VCS_DIR ]]; then
local -a msg
- local dir=$PWD
+ local dir=${GIT_DIR:-$PWD}
while true; do
msg=("${(@0)${_P9K_LAST_GIT_PROMPT[$dir]}}")
[[ $#msg != 0 || $dir == / ]] && break
@@ -1832,9 +1832,9 @@ function _p9k_vcs_gitstatus() {
[[ $POWERLEVEL9K_DISABLE_GITSTATUS == true ]] && return 1
if [[ $_P9K_REFRESH_REASON == precmd ]]; then
if [[ -v _P9K_NEXT_VCS_DIR ]]; then
- typeset -gH _P9K_NEXT_VCS_DIR=$PWD
+ typeset -gH _P9K_NEXT_VCS_DIR=${GIT_DIR:-$PWD}
else
- local dir=$PWD
+ local dir=${GIT_DIR:-$PWD}
local -F timeout=$POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS
while true; do
case "$_P9K_GIT_SLOW[$dir]" in
@@ -1844,7 +1844,7 @@ function _p9k_vcs_gitstatus() {
esac
done
typeset -gFH _P9K_GITSTATUS_START_TIME=$EPOCHREALTIME
- gitstatus_query -t $timeout -c _p9k_vcs_resume POWERLEVEL9K || return 1
+ gitstatus_query -d ${GIT_DIR:-$PWD} -t $timeout -c _p9k_vcs_resume POWERLEVEL9K || return 1
[[ $VCS_STATUS_RESULT == tout ]] && typeset -gH _P9K_NEXT_VCS_DIR=""
fi
fi I have a few questions about
If my reading of VCSH code is correct, the answers are yes and no respectively. If this is right, we'll need |
This isn't I fixed the other places you mentioned of PWD and added the only way I could see to add the |
Thanks for the contribution! |
It would be unusual if such expansion was performed, but stranger things happen in life, so who knows. I think VCSH won't expand Does it work in your environment if you set |
Oh botheration. When I tested this I was exporting the variable I was not quoting it, so it was getting expanded at assignment. Oops. For your information you don't need $ cd /tmp
$ export GIT_DIR=~/.zprezto/.git
$ git log -1 If it's working right any As such it looks like your original assessment of "yes/no" was correct. Yes it can be relative, no it does not expand '~' on it's own. |
Oh, so it's a variable recognized by FWIW, I have several bare git repos overlaying my home directory (various dotfiles, settings, etc.). I access them via aliases that pass alias dotfiles-public='git --git-dir=$HOME/.dotfiles-public/.git --work-tree=$HOME' So if I want to add a random file to my |
Yes, this is a |
Incidentally this is why I wondered if it might not be useful to implement this in |
Maybe. Another option is to make |
I've had my eye on powerlevel9k for a long time but never been convinced to take the dive until the git status caching thing in this fork hit the news wires and gave me a compelling reason to mash my configs around. One of the first things I noticed when switching from my long time theme (a fork of Agnoster) to powerlevel10k was that it did not handle VCSH repositories properly. VCSH relies on keeping the git directory in a disconnected state (out of the current directory path). Git handles this quite gracefully though the use of the
GIT_DIR
variable, butgitstatus
was ignoring this.I'm not sure if this is the best fix, perhaps it should be fixed in
gitstatus
instead, but this fix at least got me up and running. If there is a better place to fix it let me know and I'd be happy to make the contribution.