mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Merge branch 'plugin-git' into merge
Conflicts: custom/aliases.zsh plugins/git/git-aliases.plugin.zsh plugins/git/git-prompt-old.plugin.zsh plugins/git/git-prompt.plugin.zsh plugins/git/git.plugin.zsh themes/ashleydev.zsh-theme
This commit is contained in:
commit
415bdbfe6d
135 changed files with 2170 additions and 1523 deletions
|
|
@ -131,7 +131,7 @@ _git-archive () {
|
|||
'--format=-[format of the resulting archive]:archive format:__git_archive_formats' \
|
||||
'(- :)'{-l,--list}'[list available archive formats]' \
|
||||
'(-v --verbose)'{-v,--verbose}'[report progress to stderr]' \
|
||||
'--prefix=-[prepend the given path prefix to to each filename]:path prefix:_directories -r ""' \
|
||||
'--prefix=-[prepend the given path prefix to each filename]:path prefix:_directories -r ""' \
|
||||
'--output=[write archive to argument instead of stdout]:archive:_files' \
|
||||
'--worktree-attributes[look for attributes in .gitattributes in working directory too]' \
|
||||
$backend_args \
|
||||
|
|
@ -258,16 +258,22 @@ _git-branch () {
|
|||
d='-d -D'
|
||||
|
||||
declare -a dependent_creation_args
|
||||
dependent_creation_args=(
|
||||
"($l $m $d): :__git_branch_names"
|
||||
"::start-point:__git_revisions")
|
||||
if (( words[(I)-r] == 0 )); then
|
||||
dependent_creation_args=(
|
||||
"($l $m $d): :__git_branch_names"
|
||||
"::start-point:__git_revisions")
|
||||
fi
|
||||
|
||||
declare -a dependent_deletion_args
|
||||
if (( words[(I)-d] || words[(I)-D] )); then
|
||||
dependent_creation_args=
|
||||
dependent_deletion_args=(
|
||||
'-r[delete remote-tracking branches]'
|
||||
'*: :__git_ignore_line_inside_arguments __git_branch_names')
|
||||
'-r[delete only remote-tracking branches]')
|
||||
if (( words[(I)-r] )); then
|
||||
dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_remote_branch_names'
|
||||
else
|
||||
dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
|
||||
fi
|
||||
fi
|
||||
|
||||
declare -a dependent_modification_args
|
||||
|
|
@ -281,7 +287,7 @@ _git-branch () {
|
|||
_arguments -w -S -s \
|
||||
"($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
|
||||
"($c $m $d : --color)--no-color[turn off branch coloring]" \
|
||||
"($c $m $d : -a)-r[list only the remote-tracking branches]" \
|
||||
"($c $m -a)-r[list or delete only remote-tracking branches]" \
|
||||
"($c $m $d : -r)-a[list both remote-tracking branches and local branches]" \
|
||||
"($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
|
||||
"($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
|
||||
|
|
@ -2941,7 +2947,7 @@ _git-rev-parse () {
|
|||
else
|
||||
# TODO: Parse option specification?
|
||||
_arguments -w -S -s \
|
||||
'(- *)'{-h,--help}'[display usage]'
|
||||
'(- *)'{-h,--help}'[display usage]' \
|
||||
'--keep-dashdash[do not skip first -- option]' \
|
||||
'--stop-at-non-option[stop parsing options at first non-option argument]' \
|
||||
'*:option specification' && ret=0
|
||||
|
|
@ -3958,7 +3964,7 @@ _git-name-rev () {
|
|||
'--refs=[only use refs matching given pattern]: :_guard "?#" "shell pattern"' \
|
||||
'(--stdin :)--all[list all commits reachable from all refs]' \
|
||||
'(--all :)--stdin[read from stdin and append revision-name]' \
|
||||
'--name-only[display only name of commits]'
|
||||
'--name-only[display only name of commits]' \
|
||||
'--no-undefined[die with non-zero return when a reference is undefined]' \
|
||||
'--always[show uniquely abbreviated commit object as fallback]' \
|
||||
'(--stdin --all)*: :__git_commits' && ret=0
|
||||
|
|
@ -4919,7 +4925,7 @@ __git_remote_branch_names () {
|
|||
local expl
|
||||
declare -a branch_names
|
||||
|
||||
branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null)"}#refs/remotes/})
|
||||
branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}#refs/remotes/})
|
||||
__git_command_successful $pipestatus || return
|
||||
|
||||
_wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names
|
||||
|
|
@ -5162,7 +5168,7 @@ __git_files_relative () {
|
|||
|
||||
files=()
|
||||
|
||||
# Collapse "//" and "/./" into "/". Strip any remaining "/." and "/".
|
||||
# Collapse “//” and “/./” into “/”. Strip any remaining “/.” and “/”.
|
||||
for file in ${${${${${(0)1}//\/\///}//\/.\///}%/.}%/}; do
|
||||
integer i n
|
||||
(( n = $#file > $#prefix ? $#file : $#prefix ))
|
||||
|
|
@ -5413,6 +5419,10 @@ __git_guard_diff-stat-width () {
|
|||
|
||||
(( $+functions[__git_guard_number] )) ||
|
||||
__git_guard_number () {
|
||||
declare -A opts
|
||||
|
||||
zparseopts -K -D -A opts M: J: V: 1 2 n F: X:
|
||||
|
||||
_guard "[[:digit:]]#" ${1:-number}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Aliases
|
||||
alias g='git' ; compdef g=git
|
||||
# alias g='git' ; compdef g=git
|
||||
alias ga='git add' ; compdef _git ga=git-add
|
||||
alias gaa='git add --all' ; compdef _git gaa=git-add
|
||||
alias gs='git status' ; compdef _git gs=git-status
|
||||
|
|
@ -25,6 +25,7 @@ alias gcount='git shortlog -sn' ; compdef gcount=git
|
|||
alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick
|
||||
alias gm='git merge' ; compdef _git gm=git-merge
|
||||
alias glg='git log --stat --max-count=5'; compdef _git glg=git-log
|
||||
alias gls='git shortlog' ; compdef _git gls=shortlog
|
||||
|
||||
# Git history (pretty)
|
||||
local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short'
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
# Renders the name of the current branch.
|
||||
function git_prompt_info() {
|
||||
local branch=$(git_current_branch)
|
||||
if [[ -n "$branch" ]]; then
|
||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the current branch.
|
||||
function git_current_branch() {
|
||||
local ref=$(git symbolic-ref HEAD 2> /dev/null)
|
||||
if [[ -n "$ref" ]]; then
|
||||
echo "${ref#refs/heads/}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if the working tree is dirty.
|
||||
function parse_git_dirty() {
|
||||
if [[ -n $(git status -s 2> /dev/null) ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if there are commits ahead from remote.
|
||||
function git_prompt_ahead() {
|
||||
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Formats the prompt string for current git commit short SHA.
|
||||
function git_prompt_short_sha() {
|
||||
local sha=$(git rev-parse --short HEAD 2> /dev/null)
|
||||
if [[ -n "$sha" ]]; then
|
||||
echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Formats the prompt string for current git commit long SHA.
|
||||
function git_prompt_long_sha() {
|
||||
local sha=$(git rev-parse HEAD 2> /dev/null)
|
||||
if [[ -n "$sha" ]]; then
|
||||
echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the status of the working tree.
|
||||
function git_prompt_status() {
|
||||
local indicators line untracked added modified renamed deleted
|
||||
while IFS=$'\n' read line; do
|
||||
if [[ "$line" =~ '^\?\? ' ]]; then
|
||||
[[ -n $untracked ]] && continue || untracked='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_UNTRACKED}${indicators}"
|
||||
fi
|
||||
if [[ "$line" =~ '^(((A|M|D|T) )|(AD|AM|AT|MM)) ' ]]; then
|
||||
[[ -n $added ]] && continue || added='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_ADDED}${indicators}"
|
||||
fi
|
||||
if [[ "$line" =~ '^(( (M|T))|(AM|AT|MM)) ' ]]; then
|
||||
[[ -n $modified ]] && continue || modified='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_MODIFIED}${indicators}"
|
||||
fi
|
||||
if [[ "$line" =~ '^R ' ]]; then
|
||||
[[ -n $renamed ]] && continue || renamed='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_RENAMED}${indicators}"
|
||||
fi
|
||||
if [[ "$line" =~ '^( D|AD) ' ]]; then
|
||||
[[ -n $deleted ]] && continue || deleted='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_DELETED}${indicators}"
|
||||
fi
|
||||
if [[ "$line" =~ '^UU ' ]]; then
|
||||
[[ -n $unmerged ]] && continue || unmerged='yes'
|
||||
indicators="${ZSH_THEME_GIT_PROMPT_UNMERGED}${indicators}"
|
||||
fi
|
||||
done < <(git status --porcelain 2> /dev/null)
|
||||
echo $indicators
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,3 +1,2 @@
|
|||
source $ZSH/plugins/git/git-aliases.plugin.zsh
|
||||
source $ZSH/plugins/git/git-prompt-old.plugin.zsh
|
||||
source $ZSH/plugins/git/git-prompt.plugin.zsh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue