pure icon indicating copy to clipboard operation
pure copied to clipboard

Turn off `git` information

Open bigH opened this issue 4 years ago • 11 comments

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?

bigH avatar Sep 05 '19 20:09 bigH

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?

sindresorhus avatar Sep 05 '19 20:09 sindresorhus

That didn't work.

bigH avatar Sep 06 '19 06:09 bigH

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

sindresorhus avatar Sep 06 '19 07:09 sindresorhus

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.

mafredri avatar Sep 08 '19 16:09 mafredri

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.

sindresorhus avatar Sep 09 '19 19:09 sindresorhus

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.

torarnv avatar Sep 11 '19 13:09 torarnv

any update?

Sepehr-Hosseini-Vineti avatar Oct 09 '20 08:10 Sepehr-Hosseini-Vineti

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

sindresorhus avatar Oct 09 '20 14:10 sindresorhus

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

o6uoq avatar Feb 11 '21 11:02 o6uoq

@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)

mafredri avatar Feb 11 '21 11:02 mafredri

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.

cedarbaum avatar May 03 '22 18:05 cedarbaum