sindresorhus / pure

Pretty, minimal and fast ZSH prompt
MIT License
13.22k stars 978 forks source link

Way to ignore some git repository #577

Closed memeplex closed 3 years ago

memeplex commented 4 years ago

Sorry for using this issue to ask a question, but I don't know of a proper place to ask.

Usually my home directory is a git repository with tons of untracked files and a handful of tracked dotfiles.

I would like to remove any indication of this repository in pure.

Is there any way to achieve that? What do you suggest?

Thanks.

mafredri commented 3 years ago

Hi, you could achieve this quite easily by doing a small change to the Pure source code:

diff --git pure.zsh pure.zsh
index 57bb054..b732555 100644
--- pure.zsh
+++ pure.zsh
@@ -268,7 +268,9 @@ prompt_pure_async_vcs_info() {
    zstyle ':vcs_info:git*' formats '%b' '%R' '%a'
    zstyle ':vcs_info:git*' actionformats '%b' '%R' '%a'

-   vcs_info
+   if [[ $HOME != $(git rev-parse --show-toplevel 2>/dev/null) ]]; then
+       vcs_info
+   fi

    local -A info
    info[pwd]=$PWD

There may be other, and better, ways. This was a quick hack, you could look at the zsh vcs_info documentation to see if there's a way to do it that way. Currently we have no way to define that a git repository should be ignored, but we do avoid performing git fetch in $HOME.

memeplex commented 3 years ago

Thanks for the tip! I opted for a different solution which "hides" the git repository, something like:

alias home="git --git-dir $HOME/.git-home --work-tree=$HOME"

This play better with other software, not only pure.

aheckler commented 2 years ago

I was able to achieve this by adding a line to .zshrc:

zstyle ':vcs_info:*:*:Adam' formats "%0.0r"

... where Adam is of course my username. Source:

https://unix.stackexchange.com/questions/494090/how-can-i-disable-vcs-info-for-a-specific-repository

I'm not 100% sure this is the ideal/proper way, but it does cause my $HOME dotfiles repo to be ignored, but other repos nested inside $HOME work OK.

Screenshot taken on 2021-12-16 at 12 02 08 UTC@2x