Skip to content
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

Turn off git information #497

Open
bigH opened this issue Sep 5, 2019 · 11 comments
Open

Turn off git information #497

bigH opened this issue Sep 5, 2019 · 11 comments

Comments

@bigH
Copy link

bigH commented Sep 5, 2019

Pure is fantastic! I use it everywhere I can.

To that end, installing it on remote servers is useful, but I find the git information there useless as I don't issue any git commands or care about git in those contexts.

Can I turn the git integration off completely?

@sindresorhus sindresorhus changed the title Turn of git information Turn off git information Sep 5, 2019
@sindresorhus
Copy link
Owner

sindresorhus commented Sep 5, 2019

Makes sense. This would also be useful for people that use Mercurial (#313).

I think we could implement the setting like we did with colors, using zstyle.

Maybe zstyle :prompt:pure git false?

@mafredri Thoughts?

@bigH
Copy link
Author

bigH commented Sep 6, 2019

That didn't work.

@sindresorhus
Copy link
Owner

@bigH It's not implemented yet. I'm suggesting a possible API for it.

@mafredri
Copy link
Collaborator

mafredri commented Sep 8, 2019

I think we could do that, but TBH the zstyle syntax always confuses me, there also doesn't seem to be a best practice.

Do we use:

  • zstyle :prompt:pure git false like you suggested, or...
  • zstyle :prompt:pure:git enable false (or disable true)
  • zstyle :prompt:pure:vcs git false, etc...

These all look different when viewing the output of zstyle too.

@sindresorhus
Copy link
Owner

I guess there's no way to do zstyle :prompt:pure:git false which would have been the nicest.

I think we should go for zstyle :prompt:pure:git isEnabled false, and we standardize on isEnabled for anything that is toggled. Can we use camelCase? Alternatively, enabled.

@torarnv
Copy link

torarnv commented Sep 11, 2019

This would be very nice indeed. With iTerm2 now supporting a dedicated statusbar that can provide much of this information it would be nice if pure could be configured do do as little as possible, so that the extras can be offloaded off to the statusbar.

@Sepehr-Hosseini-Vineti
Copy link

any update?

@sindresorhus
Copy link
Owner

@Sepehr-Hosseini-Vineti https://twitter.com/slicknet/status/782274190451671040

@o6uoq
Copy link

o6uoq commented Feb 11, 2021

Does Pure support being able to do this per-repo/dir like Oh My Zsh does?

OMZ example:

.git/config
[oh-my-zsh]
hide-status = 1
hide-info = 1

@mafredri
Copy link
Collaborator

mafredri commented Feb 11, 2021

@o6uoq we don't support it, but it's a nice thought. Although, I'd like to see some standardization around this, there's no point in every shell setup doing their own thing, it'd be much nicer if it was, say, under [shell-prompt]. I've been considering a more global way to turn it off (e.g. via zstyle or array configuration), but we have nothing concrete yet.

Pros of .git/config:

  • Portable
  • Potentially cross-shell/theme (with standardization)

Cons:

  • We have to always read .git/config or use the git cli tool to find the settings
  • Might make the prompt seem more unresponsive (due to reading the setting)
  • A new, third way, to configure Pure (currently zstyle and env vars)

@cedarbaum
Copy link

Not a general solution, but I had a use case for only removing the Git prompt in my $HOME directory (since I have a repo there to backup config). Could be adapted to check something like git config --get oh-my-zsh.hide-status - patch below in case anyone finds it useful:

diff --git a/pure.zsh b/pure.zsh
index fc4e85c..510c90c 100644
--- a/pure.zsh
+++ b/pure.zsh
@@ -143,21 +143,23 @@ prompt_pure_preprompt_render() {
 	preprompt_parts+=('%F{${prompt_pure_colors[path]}}%~%f')
 
 	# Git branch and dirty status info.
-	typeset -gA prompt_pure_vcs_info
-	if [[ -n $prompt_pure_vcs_info[branch] ]]; then
-		preprompt_parts+=("%F{$git_color}"'${prompt_pure_vcs_info[branch]}'"%F{$git_dirty_color}"'${prompt_pure_git_dirty}%f')
-	fi
-	# Git action (for example, merge).
-	if [[ -n $prompt_pure_vcs_info[action] ]]; then
-		preprompt_parts+=("%F{$prompt_pure_colors[git:action]}"'$prompt_pure_vcs_info[action]%f')
-	fi
-	# Git pull/push arrows.
-	if [[ -n $prompt_pure_git_arrows ]]; then
-		preprompt_parts+=('%F{$prompt_pure_colors[git:arrow]}${prompt_pure_git_arrows}%f')
-	fi
-	# Git stash symbol (if opted in).
-	if [[ -n $prompt_pure_git_stash ]]; then
-		preprompt_parts+=('%F{$prompt_pure_colors[git:stash]}${PURE_GIT_STASH_SYMBOL:-≡}%f')
+	if [[ $prompt_pure_vcs_info[top] != $HOME ]]; then
+		typeset -gA prompt_pure_vcs_info
+		if [[ -n $prompt_pure_vcs_info[branch] ]]; then
+			preprompt_parts+=("%F{$git_color}"'${prompt_pure_vcs_info[branch]}'"%F{$git_dirty_color}"'${prompt_pure_git_dirty}%f')
+		fi
+		# Git action (for example, merge).
+		if [[ -n $prompt_pure_vcs_info[action] ]]; then
+			preprompt_parts+=("%F{$prompt_pure_colors[git:action]}"'$prompt_pure_vcs_info[action]%f')
+		fi
+		# Git pull/push arrows.
+		if [[ -n $prompt_pure_git_arrows ]]; then
+			preprompt_parts+=('%F{$prompt_pure_colors[git:arrow]}${prompt_pure_git_arrows}%f')
+		fi
+		# Git stash symbol (if opted in).
+		if [[ -n $prompt_pure_git_stash ]]; then
+			preprompt_parts+=('%F{$prompt_pure_colors[git:stash]}${PURE_GIT_STASH_SYMBOL:-≡}%f')
+		fi
 	fi
 
 	# Execution time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants