-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Add Git stash support #462
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0019ee5
Implement support for git stash
carhartl 815fb41
Simplify counting stashes
carhartl 917ec33
Make git stash symbol configurable
carhartl e9df830
Adapt readme to include git stash symbol
carhartl 2e45abe
Apply stash symbol color using zstyle
carhartl c2d72a8
Adapt stash status to require opt-in via zstyle
carhartl 5397f7b
Account for function being invoked asynchronously
carhartl d5f3c7d
Fix some typos
carhartl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,11 @@ prompt pure | |
| **`PURE_PROMPT_VICMD_SYMBOL`** | Defines the prompt symbol used when the `vicmd` keymap is active (VI-mode). | `❮` | | ||
| **`PURE_GIT_DOWN_ARROW`** | Defines the git down arrow symbol. | `⇣` | | ||
| **`PURE_GIT_UP_ARROW`** | Defines the git up arrow symbol. | `⇡` | | ||
| **`PURE_GIT_STASH_SYMBOL`** | Defines the git stash symbol. | `≡` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in the comments, this should be |
||
|
||
Showing git stash status as part of the prompt is not activated by default. To activate this you'll need to opt in via `zstyle`: | ||
|
||
`zstyle :prompt:pure:git:stash show yes` | ||
|
||
## Colors | ||
|
||
|
@@ -82,6 +86,7 @@ As explained in ZSH's [manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-E | |
Colors can be changed by using [`zstyle`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fzutil-Module) with a pattern of the form `:prompt:pure:$color_name` and style `color`. The color names, their default, and what part they affect are: | ||
- `execution_time` (yellow) - The execution time of the last command when exceeding `PURE_CMD_MAX_EXEC_TIME`. | ||
- `git:arrow` (cyan) - For `PURE_GIT_UP_ARROW` and `PURE_GIT_DOWN_ARROW`. | ||
- `git:stash` (cyan) - For `PURE_GIT_STASH_SYMBOL`. | ||
- `git:branch` (242) - The name of the current branch when in a Git repository. | ||
- `git:branch:cached` (red) - The name of the current branch when the data isn't fresh. | ||
- `git:action` (242) - The current action in progress (cherry-pick, rebase, etc.) when in a Git repository. | ||
|
@@ -100,11 +105,12 @@ The following diagram shows where each color is applied on the prompt: | |
┌───────────────────────────────────────────── path | ||
│ ┌────────────────────────────────── git:branch | ||
│ │ ┌─────────────────────────── git:action | ||
| | | ┌─────────────────── git:dirty | ||
│ │ │ ┌─────────────────── git:dirty | ||
│ │ │ │ ┌───────────────── git:arrow | ||
│ │ │ │ │ ┌──────── host | ||
│ │ │ │ │ │ | ||
~/dev/pure master|rebase-i* ⇡ zaphod@heartofgold 42s | ||
│ │ │ │ │ ┌─────────────── git:stash | ||
│ │ │ │ │ │ ┌────── host | ||
│ │ │ │ │ │ │ | ||
~/dev/pure master|rebase-i* ⇡ ≡ zaphod@heartofgold 42s | ||
venv ❯ │ │ | ||
│ │ │ └───── execution_time | ||
│ │ └──────────────────────── user | ||
|
@@ -141,6 +147,9 @@ zstyle :prompt:pure:path color white | |
# change the color for both `prompt:success` and `prompt:error` | ||
zstyle ':prompt:pure:prompt:*' color cyan | ||
|
||
# turn on git stash status | ||
zstyle :prompt:pure:git:stash show yes | ||
|
||
prompt pure | ||
``` | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m guessing there are no repercussions from including
%a
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason it was producing an error whenformats
didn't have the same amount asactionformats
. I really don't understand why these two seem to interact, maybe I did something wrong elsewhere, still new to zsh internals.EDIT: not an error, but something that looked like an error, but was just not the expected output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, it’s been a while since I worked with vcs_info as well so just being cautious 😄. It’s probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a second look...
%m
was only required informats
only, but not inactionformats
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. How about when a git rebase is active? That’s when action formats kick in AFAICR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the actionformats are for when git is performing a merge or rebase. If I understand all this correctly, if we were omitting
%m
from actionformats,info[stash]=$vcs_info_msg_3_
would remain empty (?) and the stash symbol would never be shown during such an action. Which is what we want?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to ensure that
$vcs_info_msg_3_
would always point to the expected output...