Commit 00eb4658 authored by Andrew Janke's avatar Andrew Janke
Browse files

Merge branch 'master' into fold-terminalapp-plugin-into-termsupport

parents 47d19cc5 192de6bc
## git
**Maintainer:** [Stibbons](https://github.com/Stibbons)
This plugin adds several git aliases and increase the completion function provided by zsh
**Maintainer:** [@ncanceill](https://github.com/ncanceill)
This plugin adds many useful aliases and functions.
### Usage
See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin.
#compdef git-branch
_git-branch ()
{
declare l c m d
l='--color --no-color -r -a --all -v --verbose --abbrev --no-abbrev'
c='-l -f --force -t --track --no-track --set-upstream --contains --merged --no-merged'
m='-m -M'
d='-d -D'
declare -a dependent_creation_args
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 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
if (( words[(I)-m] || words[(I)-M] )); then
dependent_creation_args=
dependent_modification_args=(
':old or new branch name:__git_branch_names'
'::new branch name:__git_branch_names')
fi
_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 -a --all)-r[list or delete only remote-tracking branches]" \
"($c $m $d : -r)"{-a,--all}"[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" \
"($c $m $d :)--no-abbrev[do not abbreviate sha1s]" \
"($l $m $d)-l[create the branch's reflog]" \
"($l $m $d -f --force)"{-f,--force}"[force the creation of a new branch]" \
"($l $m $d -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
"($l $m $d)--no-track[override the branch.autosetupmerge configuration variable]" \
"($l $m $d)--set-upstream[set up configuration so that pull merges]" \
"($l $m $d)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
"($l $m $d)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
"($l $m $d)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
$dependent_creation_args \
"($l $c $d -M)-m[rename a branch and the corresponding reflog]" \
"($l $c $d -m)-M[rename a branch even if the new branch-name already exists]" \
$dependent_modification_args \
"($l $c $m -D)-d[delete a fully merged branch]" \
"($l $c $m -d)-D[delete a branch]" \
$dependent_deletion_args
}
(( $+functions[__git_ignore_line] )) ||
__git_ignore_line () {
declare -a ignored
ignored=()
((CURRENT > 1)) &&
ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
((CURRENT < $#line)) &&
ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
$* -F ignored
}
(( $+functions[__git_ignore_line_inside_arguments] )) ||
__git_ignore_line_inside_arguments () {
declare -a compadd_opts
zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
__git_ignore_line $* $compadd_opts
}
#compdef git-remote
# NOTE: --track is undocumented.
# TODO: --track, -t, --master, and -m should take remote branches, I guess.
# NOTE: --master is undocumented.
# NOTE: --fetch is undocumented.
_git-remote () {
local curcontext=$curcontext state line
declare -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options' && ret=0
case $state in
(command)
declare -a commands
commands=(
'add:add a new remote'
'show:show information about a given remote'
'prune:delete all stale tracking branches for a given remote'
'update:fetch updates for a set of remotes'
'rm:remove a remote from .git/config and all associated tracking branches'
'rename:rename a remote from .git/config and update all associated tracking branches'
'set-head:sets or deletes the default branch'
'set-branches:changes the list of branches tracked by the named remote.'
'set-url:changes URL remote points to.'
)
_describe -t commands 'sub-command' commands && ret=0
;;
(options)
case $line[1] in
(add)
_arguments \
'*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \
'(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \
'(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \
':branch name:__git_remotes' \
':url:_urls' && ret=0
;;
(show)
_arguments \
'-n[do not contact the remote for a list of branches]' \
':remote:__git_remotes' && ret=0
;;
(prune)
_arguments \
'(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \
':remote:__git_remotes' && ret=0
;;
(update)
__git_remote-groups && ret=0
;;
(rm)
__git_remotes && ret=0
;;
(rename)
__git_remotes && ret=0
;;
(set-url)
_arguments \
'*--push[manipulate push URLs]' \
'(--add)--add[add URL]' \
'(--delete)--delete[delete URLs]' \
':branch name:__git_remotes' \
':url:_urls' && ret=0
;;
esac
;;
esac
}
# Query/use custom command for `git`.
zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
: ${_omz_git_git_cmd:=git}
#
# Functions
#
# The current branch name
# Usage example: git pull origin $(current_branch)
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
# it's not a symbolic ref, but in a Git repo.
function current_branch() {
local ref
ref=$($_omz_git_git_cmd symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$($_omz_git_git_cmd rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}
# The list of remotes
function current_repository() {
if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
return
fi
echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
}
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
}
# Warn if the current branch is a WIP
function work_in_progress() {
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
echo "WIP!!"
fi
}
#
# Aliases
# (sorted alphabetically)
#
alias g='git'
compdef g=git
alias gst='git status'
compdef _git gst=git-status
alias gd='git diff'
compdef _git gd=git-diff
alias gdc='git diff --cached'
compdef _git gdc=git-diff
alias gdt='git diff-tree --no-commit-id --name-only -r'
compdef _git gdc=git diff-tree --no-commit-id --name-only -r
alias gl='git pull'
compdef _git gl=git-pull
alias gup='git pull --rebase'
compdef _git gup=git-fetch
alias gp='git push'
compdef _git gp=git-push
alias gd='git diff'
gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gdt='git difftool'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gb='git branch'
alias gba='git branch -a'
alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gc='git commit -v'
compdef _git gc=git-commit
alias gc!='git commit -v --amend'
compdef _git gc!=git-commit
alias gca='git commit -v -a'
compdef _git gc=git-commit
alias gca!='git commit -v -a --amend'
compdef _git gca!=git-commit
alias gcan!='git commit -v -a -s --no-edit --amend'
alias gcb='git checkout -b'
alias gcf='git config --list'
alias gcl='git clone --recursive'
alias gclean='git reset --hard && git clean -dfx'
alias gcm='git checkout master'
alias gcmsg='git commit -m'
compdef _git gcmsg=git-commit
alias gco='git checkout'
compdef _git gco=git-checkout
alias gcm='git checkout master'
alias gr='git remote'
compdef _git gr=git-remote
alias grv='git remote -v'
compdef _git grv=git-remote
alias grmv='git remote rename'
compdef _git grmv=git-remote
alias grrm='git remote remove'
compdef _git grrm=git-remote
alias grset='git remote set-url'
compdef _git grset=git-remote
alias grup='git remote update'
compdef _git grset=git-remote
alias grbi='git rebase -i'
compdef _git grbi=git-rebase
alias grbc='git rebase --continue'
compdef _git grbc=git-rebase
alias grba='git rebase --abort'
compdef _git grba=git-rebase
alias gb='git branch'
compdef _git gb=git-branch
alias gba='git branch -a'
compdef _git gba=git-branch
alias gbr='git branch --remote'
alias gcount='git shortlog -sn'
compdef gcount=git
alias gcl='git config --list'
alias gcp='git cherry-pick'
compdef _git gcp=git-cherry-pick
alias glg='git log --stat --max-count=10'
compdef _git glg=git-log
alias glgg='git log --graph --max-count=10'
compdef _git glgg=git-log
alias glgga='git log --graph --decorate --all'
compdef _git glgga=git-log
alias glo='git log --oneline --decorate --color'
compdef _git glo=git-log
alias glog='git log --oneline --decorate --color --graph'
compdef _git glog=git-log
alias gss='git status -s'
compdef _git gss=git-status
alias ga='git add'
compdef _git ga=git-add
alias gap='git add --patch'
alias gm='git merge'
compdef _git gm=git-merge
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'
alias gclean='git reset --hard && git clean -dfx'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
# Sign and verify commits with GPG
alias gcs='git commit -S'
compdef _git gcs=git-commit
alias gsps='git show --pretty=short --show-signature'
compdef _git gsps=git-show
# Sign and verify tags with GPG
alias gts='git tag -s'
compdef _git gts=git-tag
alias gvt='git verify-tag'
compdef _git gvt=git verify-tag
#remove the gf alias
#alias gf='git ls-files | grep'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdt='git diff-tree --no-commit-id --name-only -r'
gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gdw='git diff --word-diff'
alias gpoat='git push origin --all && git push origin --tags'
alias gmt='git mergetool --no-prompt'
compdef _git gm=git-mergetool
alias gf='git fetch'
alias gfa='git fetch --all --prune'
function gfg() { git ls-files | grep $@ }
compdef gfg=grep
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias gk='gitk --all --branches'
alias gsts='git stash show --text'
alias gsta='git stash'
alias gstp='git stash pop'
alias gstd='git stash drop'
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef git-svn-dcommit-push=git
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
ggf() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
git push --force origin "${b:=$1}"
}
function current_repository() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo $(git remote -v | cut -d':' -f 2)
compdef _git ggf=git-checkout
ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
git pull origin "${b:=$1}"
fi
}
# these aliases take advantage of the previous function
compdef _git ggl=git-checkout
alias ggpull='git pull origin $(current_branch)'
compdef ggpull=git
alias ggpur='git pull --rebase origin $(current_branch)'
compdef ggpur=git
compdef _git ggpull=git-checkout
ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
git push origin "${b:=$1}"
fi
}
compdef _git ggp=git-checkout
alias ggpush='git push origin $(current_branch)'
compdef ggpush=git
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
compdef ggpnp=git
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
compdef _git ggpush=git-checkout
ggpnp() {
if [[ "$#" == 0 ]]; then
ggl && ggp
else
ggl "${*}" && ggp "${*}"
fi
}
alias glp="_git_log_prettily"
compdef _git glp=git-log
# Work In Progress (wip)
# These features allow to pause a branch development and switch to another one (wip)
# When you want to go back to work, just unwip it
#
# This function return a warning if the current branch is a wip
function work_in_progress() {
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
echo "WIP!!"
fi
compdef _git ggpnp=git-checkout
alias ggsup='git branch --set-upstream-to=origin/$(current_branch)'
ggu() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
git pull --rebase origin "${b:=$1}"
}
# these alias commit and uncomit wip branches
alias gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit -m "--wip--"'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
compdef _git ggu=git-checkout
alias ggpur='ggu'
compdef _git ggpur=git-checkout
# these alias ignore changes to file
alias gignore='git update-index --assume-unchanged'
alias gunignore='git update-index --no-assume-unchanged'
# list temporarily ignored files
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef git-svn-dcommit-push=git
alias gk='\gitk --all --branches'
compdef _git gk='gitk'
alias gke='\gitk --all $(git log -g --pretty=format:%h)'
compdef _git gke='gitk'
alias gl='git pull'
alias glg='git log --stat --color'
alias glgp='git log --stat --color -p'
alias glgg='git log --graph --color'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate --color'
alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
alias glog='git log --oneline --decorate --color --graph'
alias glp="_git_log_prettily"
compdef _git glp=git-log
alias gm='git merge'
alias gmom='git merge origin/master'
alias gmt='git mergetool --no-prompt'
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
alias gmum='git merge upstream/master'
alias gp='git push'
alias gpd='git push --dry-run'
alias gpoat='git push origin --all && git push origin --tags'
compdef _git gpoat=git-push
alias gpu='git push upstream'
alias gpv='git push -v'
alias gr='git remote'
alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase -i'
alias grbm='git rebase master'
alias grbs='git rebase --skip'
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'
alias grmv='git remote rename'
alias grrm='git remote remove'
alias grset='git remote set-url'
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
alias gru='git reset --'
alias grup='git remote update'
alias grv='git remote -v'
alias gsb='git status -sb'
alias gsd='git svn dcommit'
alias gsi='git submodule init'
alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase'
alias gss='git status -s'
alias gst='git status'
alias gsta='git stash'
alias gstaa='git stash apply'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
alias gsu='git submodule update'
alias gts='git tag -s'
alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
alias gup='git pull --rebase'
alias gupv='git pull --rebase -v'
alias gvt='git verify-tag'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'
......@@ -30,10 +30,10 @@ if [ -z "$script" ]; then
local -a locations
local e
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
)
for e in $locations; do
test -f $e && script="$e" && break
......@@ -76,6 +76,14 @@ __gitcomp_nl ()
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 ()
{
emulate -L zsh
......
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
......@@ -180,9 +178,9 @@ _get_comp_words_by_ref ()
}
fi
__gitcompadd ()
__gitcompappend ()
{
local i=0
local i=${#COMPREPLY[@]}
for x in $1; do
if [[ "$x" == "$3"* ]]; then
COMPREPLY[i++]="$2$x$4"
......@@ -190,6 +188,12 @@ __gitcompadd ()
done
}
__gitcompadd ()
{
COMPREPLY=()
__gitcompappend "$@"
}
# Generates completion reply, appending a space to possible completion words,
# if necessary.
# It accepts 1 to 4 arguments:
......@@ -220,6 +224,14 @@ __gitcomp ()
esac
}
# Variation of __gitcomp_nl () that appends to the existing list of
# completion candidates, COMPREPLY.
__gitcomp_nl_append ()
{
local IFS=$'\n'
__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
}
# Generates completion reply from newline-separated possible completion words
# by appending a space to all of them.
# It accepts 1 to 4 arguments:
......@@ -231,8 +243,8 @@ __gitcomp ()
# appended.
__gitcomp_nl ()
{
local IFS=$'\n'
__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
COMPREPLY=()
__gitcomp_nl_append "$@"
}
# Generates completion reply with compgen from newline-separated possible
......@@ -673,7 +685,6 @@ __git_list_porcelain_commands ()
index-pack) : plumbing;;
init-db) : deprecated;;
local-fetch) : plumbing;;
lost-found) : infrequent;;
ls-files) : plumbing;;
ls-remote) : plumbing;;
ls-tree) : plumbing;;
......@@ -687,14 +698,12 @@ __git_list_porcelain_commands ()
pack-refs) : plumbing;;
parse-remote) : plumbing;;
patch-id) : plumbing;;
peek-remote) : plumbing;;
prune) : plumbing;;
prune-packed) : plumbing;;
quiltimport) : import;;
read-tree) : plumbing;;
receive-pack) : plumbing;;
remote-*) : transport;;
repo-config) : deprecated;;
rerere) : plumbing;;
rev-list) : plumbing;;
rev-parse) : plumbing;;
......@@ -707,7 +716,6 @@ __git_list_porcelain_commands ()
ssh-*) : transport;;
stripspace) : plumbing;;
symbolic-ref) : plumbing;;
tar-tree) : deprecated;;
unpack-file) : plumbing;;
unpack-objects) : plumbing;;
update-index) : plumbing;;
......@@ -901,7 +909,7 @@ _git_add ()
esac
# XXX should we check for --update and --all options ?
__git_complete_index_file "--others --modified"
__git_complete_index_file "--others --modified --directory --no-empty-directory"
}
_git_archive ()
......@@ -1063,7 +1071,7 @@ _git_clean ()
esac
# XXX should we check for -x option ?
__git_complete_index_file "--others"
__git_complete_index_file "--others --directory"
}
_git_clone ()
......@@ -1188,7 +1196,7 @@ _git_diff ()
__git_complete_revlist_file
}
__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
"
......@@ -1491,6 +1499,12 @@ _git_mergetool ()
_git_merge_base ()
{
case "$cur" in
--*)
__gitcomp "--octopus --independent --is-ancestor --fork-point"
return
;;
esac
__gitcomp_nl "$(__git_refs)"
}
......@@ -1623,7 +1637,7 @@ _git_rebase ()
--preserve-merges --stat --no-stat
--committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace=
--autosquash
--autosquash --fork-point --no-fork-point
"
return
......@@ -1833,6 +1847,7 @@ _git_config ()
branch.*)
local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
return
;;
guitool.*.*)
......@@ -1875,6 +1890,7 @@ _git_config ()
remote.*)
local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
__gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
return
;;
url.*.*)
......@@ -1997,6 +2013,7 @@ _git_config ()
fetch.unpackLimit
format.attach
format.cc
format.coverLetter
format.headers
format.numbered
format.pretty
......@@ -2580,7 +2597,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
--*=*|*.) ;;
*) c="$c " ;;
esac
array[$#array+1]="$c"
array[${#array[@]}+1]="$c"
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
......
......@@ -60,6 +60,7 @@
# of values:
#
# verbose show number of commits ahead/behind (+/-) upstream
# name if verbose, then also show the upstream abbrev name
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
......@@ -84,13 +85,17 @@
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.
# check whether printf supports -v
__git_printf_supports_v=
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
# stores the divergence from upstream in $p
# used by GIT_PS1_SHOWUPSTREAM
__git_ps1_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
local upstream=git legacy="" verbose="" name=""
svn_remote=()
# get some config options from git-config
......@@ -106,7 +111,7 @@ __git_ps1_show_upstream ()
;;
svn-remote.*.url)
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
svn_url_pattern+="\\|$value"
svn_url_pattern="$svn_url_pattern\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
......@@ -118,6 +123,7 @@ __git_ps1_show_upstream ()
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
name) name=1 ;;
esac
done
......@@ -200,6 +206,9 @@ __git_ps1_show_upstream ()
*) # diverged from upstream
p=" u+${count#* }-${count% *}" ;;
esac
if [[ -n "$count" && -n "$name" ]]; then
p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
fi
fi
}
......@@ -250,6 +259,13 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r"
}
eread ()
{
f="$1"
shift
test -r "$f" && read "$@" <"$f"
}
# __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)
......@@ -312,9 +328,9 @@ __git_ps1 ()
local step=""
local total=""
if [ -d "$g/rebase-merge" ]; then
read b 2>/dev/null <"$g/rebase-merge/head-name"
read step 2>/dev/null <"$g/rebase-merge/msgnum"
read total 2>/dev/null <"$g/rebase-merge/end"
eread "$g/rebase-merge/head-name" b
eread "$g/rebase-merge/msgnum" step
eread "$g/rebase-merge/end" total
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
else
......@@ -322,10 +338,10 @@ __git_ps1 ()
fi
else
if [ -d "$g/rebase-apply" ]; then
read step 2>/dev/null <"$g/rebase-apply/next"
read total 2>/dev/null <"$g/rebase-apply/last"
eread "$g/rebase-apply/next" step
eread "$g/rebase-apply/last" total
if [ -f "$g/rebase-apply/rebasing" ]; then
read b 2>/dev/null <"$g/rebase-apply/head-name"
eread "$g/rebase-apply/head-name" b
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
......@@ -349,7 +365,7 @@ __git_ps1 ()
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
local head=""
if ! read head 2>/dev/null <"$g/HEAD"; then
if ! eread "$g/HEAD" head; then
if [ $pcmode = yes ]; then
PS1="$ps1pc_start$ps1pc_end"
fi
......@@ -433,7 +449,7 @@ __git_ps1 ()
local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
if [ $pcmode = yes ]; then
if [[ -n ${ZSH_VERSION-} ]]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring")
else
printf -v gitstring -- "$printf_format" "$gitstring"
......
......@@ -23,6 +23,7 @@ __go_tool_complete() {
'env[print Go environment information]'
'fix[run go tool fix on packages]'
'fmt[run gofmt on package sources]'
'generate[generate Go files by processing source]'
'get[download and install packages and dependencies]'
'help[display help]'
'install[compile and install packages and dependencies]'
......
......@@ -72,7 +72,7 @@ _gradle_tasks () {
if [ in_gradle ]; then
_gradle_arguments
if _gradle_does_task_list_need_generating; then
gradle tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
gradle tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
fi
compadd -X "==== Gradle Tasks ====" `cat .gradletasknamecache`
fi
......@@ -82,7 +82,7 @@ _gradlew_tasks () {
if [ in_gradle ]; then
_gradle_arguments
if _gradle_does_task_list_need_generating; then
gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
fi
compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache`
fi
......
#compdef grunt
#autoload
# -----------------------------------------------------------------------------
# _grunt
#
# Completion script for grunt.
# - https://github.com/gruntjs/grunt
# - https://github.com/gruntjs/grunt-cli
#
# -----------------------------------------------------------------------------
#
# Version : 0.1.2
# Author : Yonchu <yuyuchu3333@gmail.com>
# License : MIT License
# Repository : https://github.com/yonchu/grunt-zsh-completion
# Last Change : 20 Aug 2014.
#
# Copyright (c) 2013 Yonchu.
#
# -----------------------------------------------------------------------------
# USAGE
# -----
#
# Enable caching:
#
# If you want to use the cache, set the followings in your .zshrc:
#
# zstyle ':completion:*' use-cache yes
#
#
# Settings:
#
# - Show grunt file path:
# zstyle ':completion::complete:grunt::options:' show_grunt_path yes
#
# - Cache expiration days (default: 7):
# zstyle ':completion::complete:grunt::options:' expire 1
#
# - Not update options cache if target gruntfile is changed.
# zstyle ':completion::complete:grunt::options:' no_update_options yes
#
# Note that if you change the zstyle settings,
# you should delete the cache file and restart zsh.
#
# $ rm ~/.zcompcache/grunt
# $ exec zsh
#
# -----------------------------------------------------------------------------
function __grunt() {
local curcontext="$curcontext" update_policy state
local show_grunt_path update_msg gruntfile opts tasks
# Setup cache-policy.
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
if [[ -z $update_policy ]]; then
zstyle ":completion:${curcontext}:" cache-policy __grunt_caching_policy
fi
# Check show_path option.
zstyle -b ":completion:${curcontext}:options:" show_grunt_path show_grunt_path
# Get current gruntfile.
gruntfile=$(__grunt_get_gruntfile)
# Initialize opts and tasks.
opts=()
tasks=()
# Add help options.
opts+=('(- 1 *)'{-h,--help}'[Display this help text.]')
## Complete without gruntfile.
if [[ ! -f $gruntfile ]]; then
_arguments "${opts[@]}"
return
fi
## Complete with gruntfile.
# Retrieve cache.
if ! __grunt_update_cache "$gruntfile"; then
update_msg=' (cache updated)'
fi
# Make optioins completion.
if [[ ${#__grunt_opts} -gt 0 ]]; then
opts+=("${__grunt_opts[@]}")
fi
# Complete arguments.
_arguments \
"${opts[@]}" \
'*: :->tasks' \
&& return
case $state in
tasks)
if [[ $show_grunt_path == 'yes' ]]; then
update_msg="$update_msg: ${${gruntfile/#$HOME/~}%/}"
fi
# Make tasks completion.
if [[ ${#__grunt_tasks} -gt 0 ]]; then
tasks+=("${__grunt_tasks[@]}")
_describe -t grunt-task "$verbose grunt task$update_msg" tasks || return 1
fi
;;
esac
return 0
}
# Cache policy:
# The cache file name: grunt
# The cache variable name: __grunt_version __grunt_gruntfile __grunt_opts __grunt_tasks
function __grunt_update_cache() {
# TODO
local version='0.1.2'
local is_updating=0
local gruntfile="$1"
local grunt_info no_update_options cache_path
# Check no_update_options option.
zstyle -b ":completion:${curcontext}:options:" no_update_options no_update_options
if ! ( (( $+__grunt_gruntfile )) \
&& (( $+__grunt_opts )) \
&& (( $+__grunt_tasks )) ) \
&& ! _retrieve_cache 'grunt'; then
is_updating=1
fi
if [[ $gruntfile != $__grunt_gruntfile ]]; then
# Except for --help options.
__grunt_gruntfile=$gruntfile
if [[ $no_update_options == 'yes' ]]; then
if [[ $PREFIX == ${PREFIX#-} ]]; then
# Not options completions.
is_updating=1
elif [[ ${#__grunt_opts} -lt 2 ]]; then
is_updating=1
else
unset __grunt_gruntfile
fi
else
is_updating=1
fi
else
if [[ $PREFIX != ${PREFIX#-} && ${#__grunt_opts} -gt 1 ]]; then
unset __grunt_gruntfile
fi
fi
if _cache_invalid 'grunt'; then
is_updating=1
fi
# Check _grunt version.
if [[ $__grunt_version != $version ]]; then
is_updating=1
fi
if [[ $is_updating -ne 0 ]]; then
# Update caceh.
__grunt_version=$version
__grunt_gruntfile=$gruntfile
is_updating=1
grunt_info=$(grunt --help --no-color --gruntfile "$__grunt_gruntfile" 2>/dev/null)
__grunt_opts=(${(f)"$(__grunt_get_opts "$grunt_info")"})
__grunt_tasks=(${(f)"$(__grunt_get_tasks "$grunt_info")"})
_store_cache 'grunt' __grunt_version __grunt_gruntfile __grunt_opts __grunt_tasks
fi
return $is_updating
}
function __grunt_get_tasks() {
echo -E "$1" \
| grep 'Available tasks' -A 100 \
| grep '^ ' \
| sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//' \
| sed -e 's/:/\\:/g' \
| sed -e 's/ /:/'
}
function __grunt_get_opts() {
local opt_hunk opt_sep opt_num line opt
opt_hunk=$(echo -E "$1" \
| grep 'Options$' -A 100 \
| sed '1 d' \
| sed -e 's/[[:blank:]]*$//' \
)
opt_sep=()
opt_hunk=(${(f)opt_hunk})
opt_num=0
for line in "$opt_hunk[@]"; do
opt=$(echo -E "$line" | sed -e 's/^[[:blank:]]*//')
if [[ $line == $opt ]]; then
break
fi
if [[ $opt != ${opt#-} ]]; then
# Start with -
(( opt_num++ ))
opt=$(echo -E "$opt" | sed 's/^\(\(--[^ ]*\)\(, \(-[^ ]*\)\)*\) */\2\\t\4\\\t/')
fi
opt_sep[$opt_num]=("${opt_sep[$opt_num]}${opt}")
done
for line in "$opt_sep[@]"; do
opt=(${(s:\t:)line})
if [[ ${opt[1]} == '--help' ]]; then
continue
fi
if [[ ${#opt} -eq 2 ]]; then
echo -E "(${opt[1]})${opt[1]}[${opt[2]}]"
else
echo -E "(${opt[1]},${opt[2]})${opt[1]}[${opt[3]}]"
echo -E "(${opt[1]},${opt[2]})${opt[2]}[${opt[3]}]"
fi
done
}
function __grunt_get_gruntfile() {
local gruntfile
local curpath="$PWD"
while [ "$curpath" ]; do
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
if [[ -e "$gruntfile" ]]; then
echo "$gruntfile"
return
fi
done
curpath=${curpath%/*}
done
return 1
}
function __grunt_caching_policy() {
# Returns status zero if the completions cache needs rebuilding.
# Rebuild if .agignore more recent than cache.
if [[ -f $__grunt_gruntfile && $__grunt_gruntfile -nt $1 ]]; then
# Invalid cache because gruntfile is old.
return 0
fi
local -a oldp
local expire
zstyle -s ":completion:${curcontext}:options:" expire expire || expire=7
# Rebuild if cache is more than $expire days.
oldp=( "$1"(Nm+$expire) )
(( $#oldp ))
}
compdef __grunt grunt
\ No newline at end of file
To activate this script, load it into an interactive ZSH session:
% source history-substring-search.zsh
See the "history-substring-search.zsh" file for more information:
% sed -n '2,/^$/s/^#//p' history-substring-search.zsh | more
To activate this script, please include it the `plugins` variable within `~/.zshrc`
`plugins=(git history-substring-search)`
See the "history-substring-search.zsh" file for more information:
`sed -n '2,/^$/s/^#//p' history-substring-search.zsh | more`
......@@ -175,7 +175,6 @@ fi
# implementation details
#-----------------------------------------------------------------------------
setopt extendedglob
zmodload -F zsh/parameter
#
......@@ -284,6 +283,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
fi
function _history-substring-search-begin() {
setopt localoptions extendedglob
_history_substring_search_move_cursor_eol=false
_history_substring_search_query_highlight=
......@@ -350,6 +350,7 @@ function _history-substring-search-begin() {
}
function _history-substring-search-end() {
setopt localoptions extendedglob
_history_substring_search_result=$BUFFER
# move the cursor to the end of the command line
......
## history
Provides a couple of convenient aliases for using the `history` command to examine your command line history.
### Requirements
* None.
### Usage
* If `h` is called, your command history is listed. Equivalent to using `history`
* If `hsi` is called with an argument, a **case insensitive** `grep` search is performed on your command history, looking for commands that match the argument provided
* If `hsi` is called without an argument you will help on `grep` arguments
\ No newline at end of file
## HTTPie
**Maintainer:** [lululau](https://github.com/lululau)
This plugin adds completion for HTTPie, which is a command line HTTP client, a user-friendly cURL replacement.
[HTTPie Homepage](http://httpie.org)
function _httpie_completion() {
_arguments -C \
'(- 1 *)--version[display version information]' \
'(-j|--json)'{-j,--json}'[(default) Data items from the command line are serialized as a JSON object]' \
'(-f|--form)'{-f,--form}'[Data items from the command line are serialized as form fields]' \
'(--pretty)--pretty[<all,colors,format,none> Controls output processing]:options' \
'(-s|--style)'{-s,--style}'[Output coloring style]' \
'(-p|--print)'{-p,--print}'[String specifying what the output should contain: H(request headers), B(request body), h(response headers), b(response body)]' \
'(-v|--verbose)'{-v,--verbose}'[Print the whole request as well as the response. Shortcut for --print=HBbh.]' \
'(-h|--headers)'{-h,--headers}'[Print only the response headers. Shortcut for --print=h]' \
'(-b|--body)'{-b,--body}'[Print only the response body. Shortcut for --print=b]' \
'(-S|--stream)'{-S,--stream}'[Always stream the output by line, i.e., behave like `tail -f'"'"']' \
'(-o|--output)'{-o,--output}'[Save output to FILE]:file:_files' \
'(-d|--download)'{-d,--download}'[Do not print the response body to stdout. Rather, download it and store it in a file. The filename is guessed unless specified with --output filename. This action is similar to the default behaviour of wget.]' \
'(-c|--continue)'{-c,--continue}'[Resume an interrupted download. Note that the --output option needs to be specified as well.]' \
'(--session)--session[Create, or reuse and update a session. Within a session, custom headers, auth credential, as well as any cookies sent by the server persist between requests]:file:_files' \
'(--session-read-only)--session-read-only[Create or read a session without updating it form the request/response exchange]:file:_files' \
'(-a|--auth)'{-a,--auth}'[<USER:PASS> If only the username is provided (-a username), HTTPie will prompt for the password]' \
'(--auth-type)--auth-type[<basic, digest> The authentication mechanism to be used. Defaults to "basic".]' \
'(--proxy)--proxy[<PROTOCOL:PROXY_URL> String mapping protocol to the URL of the proxy]' \
'(--follow)--follow[Set this flag if full redirects are allowed (e.g. re-POST-ing of data at new Location).]' \
'(--verify)--verify[<VERIFY> Set to "no" to skip checking the host'"'"'s SSL certificate. You can also pass the path to a CA_BUNDLE file for private certs. You can also set the REQUESTS_CA_BUNDLE environment variable. Defaults to "yes".]' \
'(--timeout)--timeout[<SECONDS> The connection timeout of the request in seconds. The default value is 30 seconds]' \
'(--check-status)--check-status[By default, HTTPie exits with 0 when no network or other fatal errors occur. This flag instructs HTTPie to also check the HTTP status code and exit with an error if the status indicates one.]' \
'(--ignore-stdin)--ignore-stdin[Do not attempt to read stdin]' \
'(--help)--help[Show this help message and exit]' \
'(--traceback)--traceback[Prints exception traceback should one occur]' \
'(--debug)--debug[Prints exception traceback should one occur, and also other information that is useful for debugging HTTPie itself and for reporting bugs]' \
'1: :->cmds' \
'*: :->args' && ret=0
}
compdef _httpie_completion http
\ No newline at end of file
## JHBuild
**Maintainer:** [Miguel Vaello](https://github.com/miguxbe)
This plugin adds some jhbuild aliases and increase the completion function provided by zsh.
# Aliases
#
alias jh='jhbuild'
# Build
alias jhb='jhbuild build'
alias jhbo='jhbuild buildone'
# Checks
alias jhckb='jhbuild checkbranches'
alias jhckm='jhbuild checkmodulesets'
# Info & list
alias jhi='jhbuild info'
alias jhl='jhbuild list'
# Clean
alias jhc='jhbuild clean'
alias jhco='jhbuild cleanone'
# Run
alias jhr='jhbuild run'
# Depends
alias jhrd='jhbuild rdepends'
alias jhsd='jhbuild sysdeps'
# Update
alias jhu='jhbuild update'
alias jhuo='jhbuild updateone'
# Uninstall
alias jhun='jhbuild uninstall'
......@@ -11,13 +11,6 @@
# Usage: jira # opens a new issue
# jira ABC-123 # Opens an existing issue
open_jira_issue () {
local open_cmd
if [[ "$OSTYPE" = darwin* ]]; then
open_cmd='open'
else
open_cmd='xdg-open'
fi
if [ -f .jira-url ]; then
jira_url=$(cat .jira-url)
elif [ -f ~/.jira-url ]; then
......@@ -39,15 +32,22 @@ open_jira_issue () {
if [ -z "$1" ]; then
echo "Opening new issue"
$open_cmd "${jira_url}/secure/CreateIssue!default.jspa"
open_command "${jira_url}/secure/CreateIssue!default.jspa"
elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
jira_query $@
else
echo "Opening issue #$1"
else
local addcomment=''
if [[ "$2" == "m" ]]; then
addcomment="#add-comment"
echo "Add comment to issue #$1"
else
echo "Opening issue #$1"
fi
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
$open_cmd "$jira_url/issues/$jira_prefix$1"
open_command "$jira_url/issues/$jira_prefix$1$addcomment"
else
$open_cmd "$jira_url/browse/$jira_prefix$1"
open_command "$jira_url/browse/$jira_prefix$1$addcomment"
fi
fi
}
......@@ -83,7 +83,7 @@ jira_query () {
return 1
fi
echo "Browsing issues ${verb} ${preposition} ${jira_name}"
$open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
}
alias jira='open_jira_issue'
......
......@@ -13,7 +13,7 @@ jump() {
}
mark() {
if (( $# == 0 )); then
if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
MARK=$(basename "$PWD")
else
MARK="$1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment