1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-18 05:40:07 +00:00

Merge branch 'master' into dritter/test-ratio

This commit is contained in:
Dominik Ritter 2015-04-02 02:03:11 +02:00
commit a9fcd466a3
2 changed files with 38 additions and 4 deletions

View file

@ -15,6 +15,7 @@ information in configurable prompt segments.
* branch / tag name * branch / tag name
* current action status (rebasing, merging, etc.,) * current action status (rebasing, merging, etc.,)
* being behind / ahead of your remote by some number of commits * being behind / ahead of your remote by some number of commits
* number of stashes (git only)
* conditionally shows remote tracking branch if the name differs from local * conditionally shows remote tracking branch if the name differs from local
* various working tree statuses (e.g., unstaged, staged, etc.,) * various working tree statuses (e.g., unstaged, staged, etc.,)
* Shows return-code of the last command if it is an error code * Shows return-code of the last command if it is an error code
@ -111,9 +112,26 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`:
By default, the `vcs` segment will provide quite a bit of information. If you By default, the `vcs` segment will provide quite a bit of information. If you
would also like for it to display the current hash / changeset, simply define would also like for it to display the current hash / changeset, simply define
`POWERLEVEL9K_SHOW_CHANGESET` in your `~/.zshrc`: `POWERLEVEL9K_SHOW_CHANGESET` in your `~/.zshrc`. If activated, it will show
the first 12 characters of the changeset id. To change the amount of characters,
set `POWERLEVEL9K_CHANGESET_HASH_LENTH` to any value you want.
Example:
# enable the vcs segment in general
POWERLEVEL9K_SHOW_CHANGESET=true POWERLEVEL9K_SHOW_CHANGESET=true
# just show the 6 first characters of changeset
POWERLEVEL9K_CHANGESET_HASH_LENGTH=6
##### Symbols
The `vcs` segment uses various symbols to tell you the state of your repository:
* `↑4` - The number of commits your repository is ahead of your remote branch
* `↓5` - The number of commits your repository is behind of your remote branch
* `⍟3` - The number of stashes, here 3.
* `●` - There are unstaged changes in your working copy
* `✚` - There are staged changes in your working copy
* `?` - There are files in your working copy, that are unknown to your repository
### Styling ### Styling

View file

@ -53,8 +53,13 @@ autoload -Uz vcs_info
local VCS_WORKDIR_DIRTY=false local VCS_WORKDIR_DIRTY=false
local VCS_CHANGESET_PREFIX='' local VCS_CHANGESET_PREFIX=''
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
# Just display the first 12 characters of our changeset-ID. # Default: Just display the first 12 characters of our changeset-ID.
VCS_CHANGESET_PREFIX="%F{$DEFAULT_COLOR_DARK}%12.12i@%f" local VCS_CHANGESET_HASH_LENGTH=12
if [[ -n $POWERLEVEL9K_CHANGESET_HASH_LENGTH ]]; then
VCS_CHANGESET_HASH_LENGTH=$POWERLEVEL9K_CHANGESET_HASH_LENGTH
fi
VCS_CHANGESET_PREFIX="%F{$DEFAULT_COLOR_DARK}%0.$VCS_CHANGESET_HASH_LENGTH""i@%f"
fi fi
zstyle ':vcs_info:*' enable git hg zstyle ':vcs_info:*' enable git hg
@ -66,7 +71,7 @@ zstyle ':vcs_info:*' actionformats " %b %F{red}| %a%f"
zstyle ':vcs_info:*' stagedstr " %F{$DEFAULT_COLOR}$VCS_STAGED_ICON%f" zstyle ':vcs_info:*' stagedstr " %F{$DEFAULT_COLOR}$VCS_STAGED_ICON%f"
zstyle ':vcs_info:*' unstagedstr " %F{$DEFAULT_COLOR}$VCS_UNSTAGED_ICON%f" zstyle ':vcs_info:*' unstagedstr " %F{$DEFAULT_COLOR}$VCS_UNSTAGED_ICON%f"
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-remotebranch git-tagname zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-stash git-remotebranch git-tagname
# For Hg, only show the branch name # For Hg, only show the branch name
zstyle ':vcs_info:hg*:*' branchformat "%b" zstyle ':vcs_info:hg*:*' branchformat "%b"
@ -203,6 +208,17 @@ function +vi-git-tagname() {
[[ -n ${tag} ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f" [[ -n ${tag} ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f"
} }
# Show count of stashed changes
# Port from https://github.com/whiteinge/dotfiles/blob/5dfd08d30f7f2749cfc60bc55564c6ea239624d9/.zsh_shouse_prompt#L268
function +vi-git-stash() {
local -a stashes
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" %F{$DEFAULT_COLOR}⍟${stashes}%f"
fi
}
function +vi-vcs-detect-changes() { function +vi-vcs-detect-changes() {
if [[ -n ${hook_com[staged]} ]] || [[ -n ${hook_com[unstaged]} ]]; then if [[ -n ${hook_com[staged]} ]] || [[ -n ${hook_com[unstaged]} ]]; then
VCS_WORKDIR_DIRTY=true VCS_WORKDIR_DIRTY=true