Обновление ohmyzsh

This commit is contained in:
2021-06-10 11:49:35 +05:00
parent 9fcc978a55
commit e7247fa93a
501 changed files with 18233 additions and 8842 deletions

View File

@@ -1,6 +1,6 @@
# Gitfast plugin
This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version..
This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version.
To use it, add `gitfast` to the plugins array in your zshrc file:
@@ -11,5 +11,5 @@ plugins=(... gitfast)
## Aliases
An earlier version of the plugin also loaded the git plugin. If you want to keep those
aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git)
aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
as well.

View File

@@ -2,25 +2,24 @@
# zsh completion wrapper for git
#
# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
# You need git's bash completion script installed somewhere, by default it
# would be the location bash-completion uses.
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# If your script is somewhere else, you can configure it on your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
#
# The recommended way to install this script is to copy to '~/.zsh/_git', and
# then add the following to your ~/.zshrc file:
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
complete ()
{
# do nothing
return 0
}
#
# You need git's bash completion script installed. By default bash-completion's
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
#
# If your bash completion script is somewhere else, you can specify the
# location in your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
@@ -28,18 +27,32 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle -s ":completion:*:*:git:*" script script
if [ -z "$script" ]; then
local -a locations
local e
local e bash_completion
bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
bash_completion='/usr/share/bash-completion/completions/'
locations=(
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
'/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git"
"$bash_completion/git"
'/etc/bash_completion.d/git' # old debian
)
for e in $locations; do
test -f $e && script="$e" && break
done
fi
local old_complete="$functions[complete]"
functions[complete]=:
COMP_WORDBREAKS=':'
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
functions[complete]="$old_complete"
__gitcompadd ()
{
compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
}
__gitcomp ()
{
@@ -47,68 +60,85 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
--*=)
;;
*)
local c IFS=$' \t\n'
local -a array
for c in ${=1}; do
c="$c${4-}"
[[ "$cur_" == *= ]] && return
local c IFS=$' \t\n' sfx
for c in ${=1}; do
if [[ $c == "--" ]]; then
[[ "$cur_" == --no-* ]] && continue
__gitcompadd "--no-..."
break
fi
if [[ -z "${4-}" ]]; then
case $c in
--*=*|*.) ;;
*) c="$c " ;;
*=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;;
*) sfx=" " ;;
esac
array+=("$c")
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
;;
esac
}
__gitcomp_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -- ${=1} && _ret=0
else
sfx="$4"
fi
__gitcompadd "$c" "${2-}" "$sfx" -q
done
}
__gitcomp_nl ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}
__gitcomp_nl_append ()
{
emulate -L zsh
local IFS=$'\n'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}
__gitcomp_file_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -f -- ${=1} && _ret=0
IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_file ()
{
emulate -L zsh
local IFS=$'\n'
compadd -f -p "${2-}" -- ${(f)1} && _ret=0
}
__gitcomp_direct ()
{
__gitcomp_nl "$1" "" "" ""
}
__gitcomp_file_direct ()
{
__gitcomp_file "$1" ""
}
__gitcomp_nl_append ()
{
__gitcomp_nl "$@"
}
__gitcomp_direct_append ()
{
__gitcomp_direct "$@"
}
_git_zsh ()
{
__gitcomp "v1.2"
}
__git_complete_command ()
{
emulate -L zsh
compset -P '*[=:]'
compadd -p "${2-}" -f -- ${=1} && _ret=0
local command="$1"
local completion_func="_git_${command//-/_}"
if (( $+functions[$completion_func] )); then
emulate ksh -c $completion_func
return 0
elif emulate ksh -c "__git_support_parseopt_helper $command"; then
emulate ksh -c "__git_complete_common $command"
return 0
else
return 1
fi
}
__git_zsh_bash_func ()
@@ -117,14 +147,12 @@ __git_zsh_bash_func ()
local command=$1
local completion_func="_git_${command//-/_}"
declare -f $completion_func >/dev/null && $completion_func && return
__git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
completion_func="_git_${expansion//-/_}"
declare -f $completion_func >/dev/null && $completion_func
__git_complete_command "$expansion"
fi
}
@@ -149,9 +177,11 @@ __git_zsh_cmd_common ()
push:'update remote refs along with associated objects'
rebase:'forward-port local commits to the updated upstream head'
reset:'reset current HEAD to the specified state'
restore:'restore working tree files'
rm:'remove files from the working tree and from the index'
show:'show various types of objects'
status:'show the working tree status'
switch:'switch branches'
tag:'create, list, delete or verify a tag object signed with GPG')
_describe -t common-commands 'common commands' list && _ret=0
}
@@ -159,8 +189,9 @@ __git_zsh_cmd_common ()
__git_zsh_cmd_alias ()
{
local -a list
list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
_describe -t alias-commands 'aliases' list $* && _ret=0
list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
_describe -t alias-commands 'aliases' list && _ret=0
}
__git_zsh_cmd_all ()
@@ -175,33 +206,43 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
local -a orig_words
local -a orig_words __git_C_args
orig_words=( ${words[@]} )
_arguments -C \
'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
'(-p --paginate)--no-pager[do not pipe git output into a pager]' \
'--git-dir=-[set the path to the repository]: :_directories' \
'--bare[treat the repository as a bare repository]' \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
'(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
'(--bare)--git-dir=[set the path to the repository]: :_directories' \
'(--git-dir)--bare[treat the repository as a bare repository]' \
'(- :)--version[prints the git suite version]' \
'--exec-path=-[path to where your core git programs are installed]:: :_directories' \
'--html-path[print the path where git''s HTML documentation is installed]' \
'--info-path[print the path where the Info files are installed]' \
'--man-path[print the manpath (see `man(1)`) for the man pages]' \
'--work-tree=-[set the path to the working tree]: :_directories' \
'--namespace=-[set the git namespace]' \
'--exec-path=[path to where your core git programs are installed]: :_directories' \
'(- :)--exec-path[print the path where your core git programs are installed]' \
'(- :)--html-path[print the path where git''s HTML documentation is installed]' \
'(- :)--info-path[print the path where the Info files are installed]' \
'(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
'--work-tree=[set the path to the working tree]: :_directories' \
'--namespace=[set the git namespace]:' \
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
'*-C[run as if git was started in the given path]: :_directories' \
'*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
case $state in
(command)
_alternative \
'alias-commands:alias:__git_zsh_cmd_alias' \
'common-commands:common:__git_zsh_cmd_common' \
'all-commands:all:__git_zsh_cmd_all' && _ret=0
_tags common-commands alias-commands all-commands
while _tags; do
_requested common-commands && __git_zsh_cmd_common
_requested alias-commands && __git_zsh_cmd_alias
_requested all-commands && __git_zsh_cmd_all
let _ret || break
done
;;
(config)
compset -P '*[=:]'
emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
local command="${words[1]}" __git_dir
@@ -209,9 +250,13 @@ __git_zsh_main ()
if (( $+opt_args[--bare] )); then
__git_dir='.'
else
__git_dir=${opt_args[--git-dir]}
__git_dir=${~opt_args[--git-dir]}
fi
for x in ${(s.:.)opt_args[-C]}; do
__git_C_args+=('-C' ${~x})
done
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )
@@ -232,8 +277,12 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
else
elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
elif (( $+functions[_${service//-/_}] )); then
emulate ksh -c _${service//-/_}
fi
let _ret && _default && _ret=0

File diff suppressed because it is too large Load Diff

View File

@@ -70,6 +70,15 @@
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
# When there is an in-progress operation such as a merge, rebase,
# revert, cherry-pick, or bisect, the prompt will include information
# related to the operation, often in the form "|<OPERATION-NAME>".
#
# When the repository has a sparse-checkout, a notification of the form
# "|SPARSE" will be included in the prompt. This can be shortened to a
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
# by setting GIT_PS1_OMITSPARSESTATE.
#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
@@ -88,7 +97,8 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.
# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
# but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
@@ -219,7 +229,7 @@ __git_ps1_show_upstream ()
if [[ -n "$count" && -n "$name" ]]; then
__git_ps1_upstream_name=$(git rev-parse \
--abbrev-ref "$upstream" 2>/dev/null)
if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
p="$p \${__git_ps1_upstream_name}"
else
p="$p ${__git_ps1_upstream_name}"
@@ -237,7 +247,7 @@ __git_ps1_show_upstream ()
# to build a gitstring.
__git_ps1_colorize_gitstring ()
{
if [[ -n "${ZSH_VERSION-}" ]]; then
if [[ -n ${ZSH_VERSION-} ]]; then
local c_red='%F{red}'
local c_green='%F{green}'
local c_lblue='%F{blue}'
@@ -255,7 +265,7 @@ __git_ps1_colorize_gitstring ()
local flags_color="$c_lblue"
local branch_color=""
if [ "$detached" = no ]; then
if [ $detached = no ]; then
branch_color="$ok_color"
else
branch_color="$bad_color"
@@ -286,6 +296,37 @@ __git_eread ()
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
# see if a cherry-pick or revert is in progress, if the user has committed a
# conflict resolution with 'git commit' in the middle of a sequence of picks or
# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
# the todo file.
__git_sequencer_status ()
{
local todo
if test -f "$g/CHERRY_PICK_HEAD"
then
r="|CHERRY-PICKING"
return 0;
elif test -f "$g/REVERT_HEAD"
then
r="|REVERTING"
return 0;
elif __git_eread "$g/sequencer/todo" todo
then
case "$todo" in
p[\ \ ]|pick[\ \ ]*)
r="|CHERRY-PICKING"
return 0
;;
revert[\ \ ]*)
r="|REVERTING"
return 0
;;
esac
fi
return 1
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -390,6 +431,13 @@ __git_ps1 ()
return $exit
fi
local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE"
fi
local r=""
local b=""
local step=""
@@ -398,11 +446,7 @@ __git_ps1 ()
__git_eread "$g/rebase-merge/head-name" b
__git_eread "$g/rebase-merge/msgnum" step
__git_eread "$g/rebase-merge/end" total
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
else
r="|REBASE-m"
fi
r="|REBASE"
else
if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
@@ -417,10 +461,8 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/REVERT_HEAD" ]; then
r="|REVERTING"
elif __git_sequencer_status; then
:
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
@@ -467,6 +509,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
local h=""
local c=""
local p=""
@@ -499,6 +542,11 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?"
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
@@ -508,21 +556,21 @@ __git_ps1 ()
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
__git_ps1_colorize_gitstring
fi
fi
b=${b##refs/heads/}
if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
__git_ps1_branch_name=$b
b="\${__git_ps1_branch_name}"
fi
local f="$w$i$s$u"
local gitstring="$c$b${f:+$z$f}$r$p"
local f="$h$w$i$s$u"
local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
if [ "$pcmode" = yes ]; then
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring")
else

View File

@@ -1,9 +1,8 @@
#!/bin/sh
url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
version="2.16.0"
url="https://raw.githubusercontent.com/felipec/git-completion"
version="1.2"
curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
git apply updates.patch
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"

View File

@@ -1,56 +0,0 @@
diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git
index e2554130..a2e3bef5 100644
--- b/plugins/gitfast/_git
+++ a/plugins/gitfast/_git
@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
local -a locations
local e
locations=(
- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+ "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
'/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo
@@ -214,8 +214,10 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
- else
+ elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
+ elif (( $+functions[_${service}] )); then
+ emulate ksh -c _${service}
fi
let _ret && _default && _ret=0
diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash
index 9c8f7380..14012cab 100644
--- b/plugins/gitfast/git-completion.bash
+++ a/plugins/gitfast/git-completion.bash
@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+if [[ "$OSTYPE" = cygwin* ]]; then
__git_complete git.exe __git_main
fi
diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh
index 97eacd78..c1de34eb 100644
--- b/plugins/gitfast/git-prompt.sh
+++ a/plugins/gitfast/git-prompt.sh
@@ -502,9 +502,11 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
- # NO color option unless in PROMPT_COMMAND mode
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring
+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+ __git_ps1_colorize_gitstring
+ fi
fi
b=${b##refs/heads/}