Skip to content

Latest commit

 

History

History
182 lines (131 loc) · 4.22 KB

README.md

File metadata and controls

182 lines (131 loc) · 4.22 KB

spaceship-git-user

Preview of the plugin

A Spaceship Prompt Section plugin that shows the current git username and email. By default, they are only shown if the local setting (git config --local user.name) differs from the default setting (git config user.name).

This is a fork of git-name by hexcowboy.

Requirements

Installation

Manually

To install this plugin you need to source it from your .zshrc

  1. Save spaceship-git-user.zsh to your home folder (~)
  2. In your .zshrc, source the plugin before you initialize spaceship. You can rename the file to anything you want.
. ~/spaceship-git-user.zsh # <------ Add this line before the following!
autoload -U promptinit; promptinit
prompt spaceship

Zgen

zgen load cimnine/spaceship-git-user spaceship-git-user.zsh main # <------ must be before loading spaceship!
zgen load spaceship-prompt/spaceship-prompt spaceship

Setup

Add git_user to your prompt.

# .zshrc or .spaceshiprc.zsh

spaceship add --before git git_user_name
spaceship add --after git_user_name git_user_email

Or if you defined an explicit prompt order:

# .zshrc or .spaceshiprc.zsh

SPACESHIP_PROMPT_ORDER=(
  # possibly other sections
  git
  git_user_name
  git_user_email
  # possibly other sections
)

You can also add this section to the right prompt:

# .zshrc or .spaceshiprc.zsh

SPACESHIP_RPROMPT_ORDER=(
  # possibly other sections
  git_user_name
  git_user_email
  # possibly other sections
)

Configuration

Use the following variables to change the behavior of the section.

SPACESHIP_GIT_x_PREFIX

SPACESHIP_GIT_EMAIL_PREFIX="with "
SPACESHIP_GIT_USER_PREFIX="as "

SPACESHIP_GIT_x_SYMBOL

SPACESHIP_GIT_EMAIL_SYMBOL="📧 "
SPACESHIP_GIT_USER_SYMBOL="👤 "

SPACESHIP_GIT_x_COLOR

SPACESHIP_GIT_EMAIL_COLOR="red"
SPACESHIP_GIT_USER_COLOR="red"

SPACESHIP_GIT_x_SHOW

# Only show the section when the default value is different from the local one.
# Default behavior.
SPACESHIP_GIT_EMAIL_SHOW="auto"
SPACESHIP_GIT_NAME_SHOW="auto"

# Always show the section
SPACESHIP_GIT_EMAIL_SHOW="always"
SPACESHIP_GIT_NAME_SHOW="always"

# Never show the section (this might be useful if you use direnv)
SPACESHIP_GIT_EMAIL_SHOW="never"
SPACESHIP_GIT_NAME_SHOW="never"

# alternative to "never"
SPACESHIP_GIT_EMAIL_SHOW=false
SPACESHIP_GIT_NAME_SHOW=false

SPACESHIP_GIT_x_INDICATION

# Only show the icon, not the actual value.
# Default behavior.
SPACESHIP_GIT_EMAIL_INDICATION="short"
SPACESHIP_GIT_NAME_INDICATION="short"

# Show the full value.
SPACESHIP_GIT_EMAIL_INDICATION="long"
SPACESHIP_GIT_NAME_INDICATION="long"

SPACESHIP_GIT_EMAIL_PART

# Show the full git email address, for example 'user@domain.tld'.
# Default behavior.
SPACESHIP_GIT_EMAIL_PART="full"

# Only show the part before the last '@', for example 'user'.
SPACESHIP_GIT_EMAIL_PART="user"

# Only show the part after the last '@', for example 'domain.tld'.
SPACESHIP_GIT_EMAIL_PART="domain"

SPACESHIP_GIT_EMAIL_PART_AFFIX

# Results in "user@…"
# Default behavior.
SPACESHIP_GIT_EMAIL_PART="user"
SPACESHIP_GIT_EMAIL_PART_AFFIX="auto"

# Results in "…@domain.tld"
# Default behavior.
SPACESHIP_GIT_EMAIL_PART="domain"
SPACESHIP_GIT_EMAIL_PART_AFFIX="auto"

# Results in "user@"
SPACESHIP_GIT_EMAIL_PART="user"
SPACESHIP_GIT_EMAIL_PART_AFFIX="@"

# Results in "@domain.tld"
SPACESHIP_GIT_EMAIL_PART="domain"
SPACESHIP_GIT_EMAIL_PART_AFFIX="@"

# Results in "user"
SPACESHIP_GIT_EMAIL_PART="user"
SPACESHIP_GIT_EMAIL_PART_AFFIX=""

# Results in "domain.tld"
SPACESHIP_GIT_EMAIL_PART="domain"
SPACESHIP_GIT_EMAIL_PART_AFFIX=""