spaceship-prompt
spaceship-prompt copied to clipboard
Modularize the git status to support customization
Modularizes the Git status section! This is discussed in #375.
Until now Spaceship has been wonderfully flexible except in the opinionated Git prompt. This PR breaks the Git prompt section into subsections analogous to the top-level sections in the full prompt, making it easy for users to customize their Git prompt and to build, share, plug in new Git prompt pieces.
Changes:
- Reworks
git.zsh
to run build the Git section from an array of subsections - Moves the Git status options to their own file, so that they can be easily used in other user subsections
- Documentation
Example usages:
Default:
SPACESHIP_GIT_ORDER=(
branch
status
)
Spaceship < v3
SPACESHIP_GIT_ORDER=(
branch
status_oh_my_zsh
)
Custom
SPACESHIP_GIT_ORDER=(
my_custom_git_prompt
)
While you are improving git sections, could you perhaps address this discovery as well and move the options to the git_branch
subsection where they belong?
SPACESHIP_GIT_PREFIX
andSPACESHIP_GIT_SYMBOL
are really branch subsection options.
@salmanulfarzy @maximbaz I've pushed some commits addressing your feedback
@maximbaz I actually think I was wrong about SPACESHIP_GIT_PREFIX
and SPACESHIP_GIT_SYMBOL
@maximbaz I actually think I was wrong about SPACESHIP_GIT_PREFIX and SPACESHIP_GIT_SYMBOL
Could you elaborate? Because currently I also think those two belong to the branch section 🙂
@maximbaz it's been long enough that I forgot exactly how it's set up :)
SPACESHIP_GIT_SYMBOL
should be in the branch subsection!
In this PR, the Git section has a prefix, and the branch subsection has one too, so SPACESHIP_GIT_PREFIX
is good as is. Unless I'm misreading again :)
I thought we could cleanup the sections/git.zsh
from all configuration options except SPACESHIP_GIT_SHOW
, for example by renaming SPACESHIP_GIT_SYMBOL
to SPACESHIP_GIT_BRANCH_SYMBOL
and moving it into the sections/git_branch.zsh
. But if that's not trivial and/or doesn't fit into your changes, better leave out for another PR.
Looking at this again to see where it stands.
I moved the git symbol
into the branch
file, as requested — thanks for sticking to your guns on that idea @maximbaz, you were right.
I personally still like the idea of a git_status_options.zsh
— that way any contributor has the option of pulling in an existing Spaceship default. In fact, it could make sense to encourage using reusing variables from git_status_options.zsh
, so that if a user wanted to switch from one git prompt to another they'd see familiar symbols in familiar parts of the prompt. (I didn't go back and read the full inline discussion from earlier, but I bet I'm just repeating myself 😉)
:tada: This issue has been resolved in version 4.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: