Commit 914c47b3 authored by Stephen Zhuang's avatar Stephen Zhuang
Browse files

Merge remote-tracking branch 'upstream/master'

parents 692dca07 80a60325
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
# as seen in http://www.porcheron.info/command-not-found-for-zsh/ # as seen in http://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu # this is installed in Ubuntu
source /etc/zsh_command_not_found [[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
# ------------------------------------------------------------------------------
# FILE: composer.plugin.zsh
# DESCRIPTION: oh-my-zsh composer plugin file.
# AUTHOR: Daniel Gomes (me@danielcsgomes.com)
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# Composer basic command completion
_composer_get_command_list () {
composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
}
_composer () {
if [ -f composer.json ]; then
compadd `_composer_get_command_list`
fi
}
compdef _composer composer
# Aliases
alias c='composer'
alias csu='composer self-update'
alias cu='composer update'
alias ci='composer install'
alias ccp='composer create-project'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
\ No newline at end of file
#Show progress while file is copying
# Rsync options are:
# -p - preserve permissions
# -o - preserve owner
# -g - preserve group
# -h - output in human-readable format
# --progress - display progress
# -b - instead of just overwriting an existing file, save the original
# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync"
# -e /dev/null - only work on local files
# -- - everything after this is an argument, even if it looks like an option
alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
# Use aptitude if installed, or apt-get if not. # Use aptitude if installed, or apt-get if not.
# You can just set apt_pref='apt-get' to override it. # You can just set apt_pref='apt-get' to override it.
if [[ -e $( which aptitude ) ]]; then if [[ -e $( which aptitude 2>&1 ) ]]; then
apt_pref='aptitude' apt_pref='aptitude'
else else
apt_pref='apt-get' apt_pref='apt-get'
fi fi
# Use sudo by default if it's installed # Use sudo by default if it's installed
if [[ -e $( which sudo ) ]]; then if [[ -e $( which sudo 2>&1 ) ]]; then
use_sudo=1 use_sudo=1
fi fi
...@@ -21,7 +21,7 @@ fi ...@@ -21,7 +21,7 @@ fi
# These are for more obscure uses of apt-get and aptitude that aren't covered # These are for more obscure uses of apt-get and aptitude that aren't covered
# below. # below.
alias ag='apt-get' alias ag='apt-get'
alias at='aptitude' alias ap='aptitude'
# Some self-explanatory aliases # Some self-explanatory aliases
alias acs="apt-cache search" alias acs="apt-cache search"
...@@ -35,7 +35,7 @@ alias afs='apt-file search --regexp' ...@@ -35,7 +35,7 @@ alias afs='apt-file search --regexp'
# These are apt-get only # These are apt-get only
alias asrc='apt-get source' alias asrc='apt-get source'
alias ap='apt-cache policy' alias app='apt-cache policy'
# superuser operations ###################################################### # superuser operations ######################################################
if [[ $use_sudo -eq 1 ]]; then if [[ $use_sudo -eq 1 ]]; then
...@@ -61,7 +61,8 @@ if [[ $use_sudo -eq 1 ]]; then ...@@ -61,7 +61,8 @@ if [[ $use_sudo -eq 1 ]]; then
# Install all .deb files in the current directory. # Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use: # Warning: you will need to put the glob in single quotes if you use:
# glob_subst # glob_subst
alias di='sudo dpkg -i ./*.deb' alias dia='sudo dpkg -i ./*.deb'
alias di='sudo dpkg -i'
# Remove ALL kernel images and headers EXCEPT the one in use # Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
...@@ -100,7 +101,8 @@ else ...@@ -100,7 +101,8 @@ else
# Install all .deb files in the current directory # Install all .deb files in the current directory
# Assumes glob_subst is off # Assumes glob_subst is off
alias di='su -lc "dpkg -i ./*.deb" root' alias dia='su -lc "dpkg -i ./*.deb" root'
alias di='su -lc "dpkg -i" root'
# Remove ALL kernel images and headers EXCEPT the one in use # Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \ alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \
......
# Open folder in ForkLift.app from console
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
#
# Usage:
# fl [<folder>]
#
# Opens specified directory or current working directory in ForkLift.app
#
# Notes:
# It assumes Shift+Cmd+G launches go to folder panel and Cmd+N opens new
# app window.
#
# https://gist.github.com/3313481
function fl {
if [ ! -z "$1" ]; then
DIR=$1
if [ ! -d "$DIR" ]; then
DIR=$(dirname $DIR)
fi
if [ "$DIR" != "." ]; then
PWD=`cd "$DIR";pwd`
fi
fi
osascript 2>&1 1>/dev/null <<END
tell application "ForkLift"
activate
end tell
tell application "System Events"
tell application process "ForkLift"
try
set topWindow to window 1
on error
keystroke "n" using command down
set topWindow to window 1
end try
keystroke "g" using {command down, shift down}
tell sheet 1 of topWindow
set value of text field 1 to "$PWD"
keystroke return
end tell
end tell
end tell
END
}
#compdef git
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for git-extras (http://github.com/visionmedia/git-extras).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Alexis GRIMALDI (https://github.com/agrimaldi)
#
# ------------------------------------------------------------------------------
# Inspirations
# -----------
#
# * git-extras (http://github.com/visionmedia/git-extras)
# * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
#
# ------------------------------------------------------------------------------
__git_command_successful () {
if (( ${#pipestatus:#0} > 0 )); then
_message 'not a git repository'
return 1
fi
return 0
}
__git_tag_names() {
local expl
declare -a tag_names
tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
__git_command_successful || return
_wanted tag-names expl tag-name compadd $* - $tag_names
}
__git_branch_names() {
local expl
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
__git_feature_branch_names() {
local expl
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
__git_refactor_branch_names() {
local expl
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
__git_bug_branch_names() {
local expl
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
__git_submodule_names() {
local expl
declare -a submodule_names
submodule_names=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"})
__git_command_successful || return
_wanted submodule-names expl submodule-name compadd $* - $submodule_names
}
__git_author_names() {
local expl
declare -a author_names
author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"})
__git_command_successful || return
_wanted author-names expl author-name compadd $* - $author_names
}
_git-changelog() {
_arguments \
'(-l --list)'{-l,--list}'[list commits]' \
}
_git-effort() {
_arguments \
'--above[ignore file with less than x commits]' \
}
_git-contrib() {
_arguments \
':author:__git_author_names'
}
_git-count() {
_arguments \
'--all[detailed commit count]'
}
_git-delete-branch() {
_arguments \
':branch-name:__git_branch_names'
}
_git-delete-submodule() {
_arguments \
':submodule-name:__git_submodule_names'
}
_git-delete-tag() {
_arguments \
':tag-name:__git_tag_names'
}
_git-extras() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C \
': :->command' \
'*:: :->option-or-argument' && ret=0
case $state in
(command)
declare -a commands
commands=(
'update:update git-extras'
)
_describe -t commands command commands && ret=0
;;
esac
_arguments \
'(-v --version)'{-v,--version}'[show current version]' \
}
_git-graft() {
_arguments \
':src-branch-name:__git_branch_names' \
':dest-branch-name:__git_branch_names'
}
_git-squash() {
_arguments \
':branch-name:__git_branch_names'
}
_git-feature() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C \
': :->command' \
'*:: :->option-or-argument' && ret=0
case $state in
(command)
declare -a commands
commands=(
'finish:merge feature into the current branch'
)
_describe -t commands command commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(finish)
_arguments -C \
':branch-name:__git_feature_branch_names'
;;
esac
esac
}
_git-refactor() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C \
': :->command' \
'*:: :->option-or-argument' && ret=0
case $state in
(command)
declare -a commands
commands=(
'finish:merge refactor into the current branch'
)
_describe -t commands command commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(finish)
_arguments -C \
':branch-name:__git_refactor_branch_names'
;;
esac
esac
}
_git-bug() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C \
': :->command' \
'*:: :->option-or-argument' && ret=0
case $state in
(command)
declare -a commands
commands=(
'finish:merge bug into the current branch'
)
_describe -t commands command commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(finish)
_arguments -C \
':branch-name:__git_bug_branch_names'
;;
esac
esac
}
zstyle ':completion:*:*:git:*' user-commands \
changelog:'populate changelog file with commits since the previous tag' \
contrib:'display author contributions' \
count:'count commits' \
delete-branch:'delete local and remote branch' \
delete-submodule:'delete submodule' \
delete-tag:'delete local and remote tag' \
extras:'git-extras' \
graft:'merge commits from source branch to destination branch' \
squash:'merge commits from source branch into the current one as a single commit' \
feature:'create a feature branch' \
refactor:'create a refactor branch' \
bug:'create a bug branch' \
summary:'repository summary' \
effort:'display effort statistics' \
repl:'read-eval-print-loop' \
commits-since:'list commits since a given date' \
release:'release commit with the given tag' \
alias:'define, search and show aliases' \
ignore:'add patterns to .gitignore' \
info:'show info about the repository' \
create-branch:'create local and remote branch' \
fresh-branch:'create empty local branch' \
undo:'remove the latest commit' \
setup:'setup a git repository' \
touch:'one step creation of new files' \
obliterate:'Completely remove a file from the repository, including past commits and tags' \
local-commits:'list unpushed commits on the local branch' \
...@@ -195,7 +195,7 @@ __git-flow-feature () ...@@ -195,7 +195,7 @@ __git-flow-feature ()
'start:Start a new feature branch.' 'start:Start a new feature branch.'
'finish:Finish a feature branch.' 'finish:Finish a feature branch.'
'list:List all your feature branches. (Alias to `git flow feature`)' 'list:List all your feature branches. (Alias to `git flow feature`)'
'publish: public' 'publish: publish'
'track: track' 'track: track'
'diff: diff' 'diff: diff'
'rebase: rebase' 'rebase: rebase'
...@@ -221,6 +221,7 @@ __git-flow-feature () ...@@ -221,6 +221,7 @@ __git-flow-feature ()
_arguments \ _arguments \
-F'[Fetch from origin before performing finish]' \ -F'[Fetch from origin before performing finish]' \
-r'[Rebase instead of merge]'\ -r'[Rebase instead of merge]'\
-k'[Keep branch after performing finish]'\
':feature:__git_flow_feature_list' ':feature:__git_flow_feature_list'
;; ;;
...@@ -236,13 +237,13 @@ __git-flow-feature () ...@@ -236,13 +237,13 @@ __git-flow-feature ()
(diff) (diff)
_arguments \ _arguments \
':branch:__git_branch_names'\ ':branch:__git_flow_feature_list'\
;; ;;
(rebase) (rebase)
_arguments \ _arguments \
-i'[Do an interactive rebase]' \ -i'[Do an interactive rebase]' \
':branch:__git_branch_names' ':branch:__git_flow_feature_list'
;; ;;
(checkout) (checkout)
...@@ -253,7 +254,7 @@ __git-flow-feature () ...@@ -253,7 +254,7 @@ __git-flow-feature ()
(pull) (pull)
_arguments \ _arguments \
':remote:__git_remotes'\ ':remote:__git_remotes'\
':branch:__git_branch_names' ':branch:__git_flow_feature_list'
;; ;;
*) *)
...@@ -333,4 +334,4 @@ __git_command_successful () { ...@@ -333,4 +334,4 @@ __git_command_successful () {
return 0 return 0
} }
zstyle ':completion:*:*:git:*' user-commands flow:'description for foo' zstyle ':completion:*:*:git:*' user-commands flow:'description for foo'
\ No newline at end of file
#!zsh
#
# Installation
# ------------
#
# To achieve git-hubflow completion nirvana:
#
# 0. Update your zsh's git-completion module to the newest verion.
# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD
#
# 1. Install this file. Either:
#
# a. Place it in your .zshrc:
#
# b. Or, copy it somewhere (e.g. ~/.git-hubflow-completion.zsh) and put the following line in
# your .zshrc:
#
# source ~/.git-hubflow-completion.zsh
#
# c. Or, use this file as a oh-my-zsh plugin.
#
_git-hf ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
local -a subcommands
subcommands=(
'init:Initialize a new git repo with support for the branching model.'
'feature:Manage your feature branches.'
'release:Manage your release branches.'
'hotfix:Manage your hotfix branches.'
'support:Manage your support branches.'
'update:Pull upstream changes down into your master and develop branches.'
'version:Shows version information.'
)
_describe -t commands 'git hf' subcommands
;;
(options)
case $line[1] in
(init)
_arguments \
-f'[Force setting of gitflow branches, even if already configured]'
;;
(version)
;;
(hotfix)
__git-hf-hotfix
;;
(release)
__git-hf-release
;;
(feature)
__git-hf-feature
;;
esac
;;
esac
}
__git-hf-release ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
local -a subcommands
subcommands=(
'start:Start a new release branch.'
'finish:Finish a release branch.'
'list:List all your release branches. (Alias to `git hf release`)'
'cancel:Cancel release'
'push:Push release to github'
'pull:Pull release from github'
'track:Track release'
)
_describe -t commands 'git hf release' subcommands
_arguments \
-v'[Verbose (more) output]'
;;
(options)
case $line[1] in
(start)
_arguments \
-F'[Fetch from origin before performing finish]'\
':version:__git_hf_version_list'
;;
(finish)
_arguments \
-F'[Fetch from origin before performing finish]' \
-s'[Sign the release tag cryptographically]'\
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
-m'[Use the given tag message]'\
-p'[Push to $ORIGIN after performing finish]'\
-k'[Keep branch after performing finish]'\
-n"[Don't tag this release]"\
':version:__git_hf_version_list'
;;
*)
_arguments \
-v'[Verbose (more) output]'
;;
esac
;;
esac
}
__git-hf-hotfix ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
local -a subcommands
subcommands=(
'start:Start a new hotfix branch.'
'finish:Finish a hotfix branch.'
'list:List all your hotfix branches. (Alias to `git hf hotfix`)'
'publish:Publish the hotfix branch.'
'track:Track the hotfix branch.'
'pull:Pull the hotfix from github.'
'push:Push the hotfix to github.'
'cancel:Cancel the hotfix.'
)
_describe -t commands 'git hf hotfix' subcommands
_arguments \
-v'[Verbose (more) output]'
;;
(options)
case $line[1] in
(start)
_arguments \
-F'[Fetch from origin before performing finish]'\
':hotfix:__git_hf_version_list'\
':branch-name:__git_branch_names'
;;
(finish)
_arguments \
-F'[Fetch from origin before performing finish]' \
-s'[Sign the release tag cryptographically]'\
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
-m'[Use the given tag message]'\
-p'[Push to $ORIGIN after performing finish]'\
-k'[Keep branch after performing finish]'\
-n"[Don't tag this release]"\
':hotfix:__git_hf_hotfix_list'
;;
*)
_arguments \
-v'[Verbose (more) output]'
;;
esac
;;
esac
}
__git-hf-feature ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
local -a subcommands
subcommands=(
'list:List all your feature branches. (Alias to `git hf feature`)'
'start:Start a new feature branch'
'finish:Finish a feature branch'
'submit:submit'
'track:track'
'diff:Diff'
'rebase:Rebase feature branch against develop'
'checkout:Checkout feature'
'pull:Pull feature branch from github'
'push:Push feature branch to github'
'cancel:Cancel feature'
)
_describe -t commands 'git hf feature' subcommands
_arguments \
-v'[Verbose (more) output]'
;;
(options)
case $line[1] in
(start)
_arguments \
-F'[Fetch from origin before performing finish]'\
':feature:__git_hf_feature_list'\
':branch-name:__git_branch_names'
;;
(finish)
_arguments \
-F'[Fetch from origin before performing finish]' \
-r'[Rebase instead of merge]'\
':feature:__git_hf_feature_list'
;;
(publish)
_arguments \
':feature:__git_hf_feature_list'\
;;
(track)
_arguments \
':feature:__git_hf_feature_list'\
;;
(diff)
_arguments \
':branch:__git_branch_names'\
;;
(rebase)
_arguments \
-i'[Do an interactive rebase]' \
':branch:__git_branch_names'
;;
(checkout)
_arguments \
':branch:__git_hf_feature_list'\
;;
(pull)
_arguments \
':remote:__git_remotes'\
':branch:__git_branch_names'
;;
*)
_arguments \
-v'[Verbose (more) output]'
;;
esac
;;
esac
}
__git_hf_version_list ()
{
local expl
declare -a versions
versions=(${${(f)"$(_call_program versions git hf release list 2> /dev/null | tr -d ' |*')"}})
__git_command_successful || return
_wanted versions expl 'version' compadd $versions
}
__git_hf_feature_list ()
{
local expl
declare -a features
features=(${${(f)"$(_call_program features git hf feature list 2> /dev/null | tr -d ' |*')"}})
__git_command_successful || return
_wanted features expl 'feature' compadd $features
}
__git_remotes () {
local expl gitdir remotes
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
__git_command_successful || return
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
__git_command_successful || return
# TODO: Should combine the two instead of either or.
if (( $#remotes > 0 )); then
_wanted remotes expl remote compadd $* - $remotes
else
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
fi
}
__git_hf_hotfix_list ()
{
local expl
declare -a hotfixes
hotfixes=(${${(f)"$(_call_program hotfixes git hf hotfix list 2> /dev/null | tr -d ' |*')"}})
__git_command_successful || return
_wanted hotfixes expl 'hotfix' compadd $hotfixes
}
__git_branch_names () {
local expl
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
__git_command_successful () {
if (( ${#pipestatus:#0} > 0 )); then
_message 'not a git repository'
return 1
fi
return 0
}
zstyle ':completion:*:*:git:*' user-commands flow:'description for foo'
_git_remote_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
if (( CURRENT == 2 )); then
# first arg: operation
compadd create publish rename delete track
elif (( CURRENT == 3 )); then
# second arg: remote branch name
compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
elif (( CURRENT == 4 )); then
# third arg: remote name
compadd `git remote`
fi
else;
_files
fi
}
compdef _git_remote_branch grb
...@@ -5,10 +5,11 @@ alias gst='git status' ...@@ -5,10 +5,11 @@ alias gst='git status'
compdef _git gst=git-status compdef _git gst=git-status
alias gl='git pull' alias gl='git pull'
compdef _git gl=git-pull compdef _git gl=git-pull
alias gup='git fetch && git rebase' alias gup='git pull --rebase'
compdef _git gup=git-fetch compdef _git gup=git-fetch
alias gp='git push' alias gp='git push'
compdef _git gp=git-push compdef _git gp=git-push
alias gd='git diff'
gdv() { git diff -w "$@" | view - } gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff compdef _git gdv=git-diff
alias gc='git commit -v' alias gc='git commit -v'
...@@ -18,18 +19,33 @@ compdef _git gca=git-commit ...@@ -18,18 +19,33 @@ compdef _git gca=git-commit
alias gco='git checkout' alias gco='git checkout'
compdef _git gco=git-checkout compdef _git gco=git-checkout
alias gcm='git checkout master' 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 gb='git branch' alias gb='git branch'
compdef _git gb=git-branch compdef _git gb=git-branch
alias gba='git branch -a' alias gba='git branch -a'
compdef _git gba=git-branch compdef _git gba=git-branch
alias gcount='git shortlog -sn' alias gcount='git shortlog -sn'
compdef gcount=git compdef gcount=git
alias gcl='git config --list'
alias gcp='git cherry-pick' alias gcp='git cherry-pick'
compdef _git gcp=git-cherry-pick compdef _git gcp=git-cherry-pick
alias glg='git log --stat --max-count=5' alias glg='git log --stat --max-count=5'
compdef _git glg=git-log compdef _git glg=git-log
alias glgg='git log --graph --max-count=5' alias glgg='git log --graph --max-count=5'
compdef _git glgg=git-log compdef _git glgg=git-log
alias glgga='git log --graph --decorate --all'
compdef _git glgga=git-log
alias gss='git status -s' alias gss='git status -s'
compdef _git gss=git-status compdef _git gss=git-status
alias ga='git add' alias ga='git add'
...@@ -38,6 +54,13 @@ alias gm='git merge' ...@@ -38,6 +54,13 @@ alias gm='git merge'
compdef _git gm=git-merge compdef _git gm=git-merge
alias grh='git reset HEAD' alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard' alias grhh='git reset HEAD --hard'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
alias gf='git ls-files | grep'
alias gpoat='git push origin --all && git push origin --tags'
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
# Git and svn mix # Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
...@@ -50,13 +73,14 @@ alias gsd='git svn dcommit' ...@@ -50,13 +73,14 @@ alias gsd='git svn dcommit'
# Usage example: git pull origin $(current_branch) # Usage example: git pull origin $(current_branch)
# #
function current_branch() { function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/} echo ${ref#refs/heads/}
} }
function current_repository() { function current_repository() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git symbolic-ref HEAD 2> /dev/null) || return ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo $(git remote -v | cut -d':' -f 2) echo $(git remote -v | cut -d':' -f 2)
} }
......
#compdef git gitk
# zsh completion wrapper for git
#
# You need git's bash completion script installed somewhere, by default on the
# same directory as this script.
#
# If your script is on ~/.git-completion.sh instead, you can configure it on
# your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
#
# The recommended way to install this script is to copy to
# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh/completion $fpath)
complete ()
{
# do nothing
return 0
}
zstyle -s ":completion:*:*:git:*" script script
test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
ZSH_VERSION='' . "$script"
__gitcomp ()
{
emulate -L zsh
local cur_="${3-$cur}"
case "$cur_" in
--*=)
;;
*)
local c IFS=$' \t\n'
local -a array
for c in ${=1}; do
c="$c${4-}"
case $c in
--*=*|*.) ;;
*) c="$c " ;;
esac
array+=("$c")
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
;;
esac
}
__gitcomp_nl ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}
_git ()
{
local _ret=1
() {
emulate -L ksh
local cur cword prev
cur=${words[CURRENT-1]}
prev=${words[CURRENT-2]}
let cword=CURRENT-1
__${service}_main
}
let _ret && _default -S '' && _ret=0
return _ret
}
_git
This diff is collapsed.
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see the current branch in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
# 2) Add the following line to your .bashrc/.zshrc:
# source ~/.git-prompt.sh
# 3) Change your PS1 to also show the current branch:
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
#
# The argument to __git_ps1 will be displayed only if you are currently
# in a git repository. The %s token will be the name of the current
# branch.
#
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
# unstaged (*) and staged (+) changes will be shown next to the branch
# name. You can configure this per-repository with the
# bash.showDirtyState variable, which defaults to true once
# GIT_PS1_SHOWDIRTYSTATE is enabled.
#
# You can also see if currently something is stashed, by setting
# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
# then a '$' will be shown next to the branch name.
#
# If you would like to see if there're untracked files, then you can set
# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
# files, then a '%' will be shown next to the branch name.
#
# If you would like to see the difference between HEAD and its upstream,
# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
# indicates you are ahead, "<>" indicates you have diverged and "="
# indicates that there is no difference. You can further control
# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
# of values:
#
# verbose show number of commits ahead/behind (+/-) upstream
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
# svn always compare HEAD to your SVN upstream
#
# 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
# setting the bash.showUpstream config variable.
# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
__gitdir ()
{
# Note: this function is duplicated in git-completion.bash
# When updating it, make sure you update the other one to match.
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"
elif [ -n "${GIT_DIR-}" ]; then
test -d "${GIT_DIR-}" || return 1
echo "$GIT_DIR"
elif [ -d .git ]; then
echo .git
else
git rev-parse --git-dir 2>/dev/null
fi
elif [ -d "$1/.git" ]; then
echo "$1/.git"
else
echo "$1"
fi
}
# 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=""
svn_remote=()
# get some config options from git-config
local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
while read -r key value; do
case "$key" in
bash.showupstream)
GIT_PS1_SHOWUPSTREAM="$value"
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
p=""
return
fi
;;
svn-remote.*.url)
svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
svn_url_pattern+="\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
done <<< "$output"
# parse configuration values
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
esac
done
# Find our upstream
case "$upstream" in
git) upstream="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local svn_upstream=($(git log --first-parent -1 \
--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
svn_upstream=${svn_upstream%@*}
local n_stop="${#svn_remote[@]}"
for ((n=1; n <= n_stop; n++)); do
svn_upstream=${svn_upstream#${svn_remote[$n]}}
done
if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream=${GIT_SVN_ID:-git-svn}
else
upstream=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream" ]]; then
upstream="@{upstream}"
fi
;;
esac
# Find how many commits we are ahead/behind our upstream
if [[ -z "$legacy" ]]; then
count="$(git rev-list --count --left-right \
"$upstream"...HEAD 2>/dev/null)"
else
# produce equivalent output to --count for older versions of git
local commits
if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
then
local commit behind=0 ahead=0
for commit in $commits
do
case "$commit" in
"<"*) ((behind++)) ;;
*) ((ahead++)) ;;
esac
done
count="$behind $ahead"
else
count=""
fi
fi
# calculate the result
if [[ -z "$verbose" ]]; then
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p=">" ;;
*" 0") # behind upstream
p="<" ;;
*) # diverged from upstream
p="<>" ;;
esac
else
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p=" u=" ;;
"0 "*) # ahead of upstream
p=" u+${count#0 }" ;;
*" 0") # behind upstream
p=" u-${count% 0}" ;;
*) # diverged from upstream
p=" u+${count#* }-${count% *}" ;;
esac
fi
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# returns text to add to bash PS1 prompt (includes branch name)
__git_ps1 ()
{
local g="$(__gitdir)"
if [ -n "$g" ]; then
local r=""
local b=""
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
else
if [ -d "$g/rebase-apply" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
b="$(
case "${GIT_PS1_DESCRIBE_STYLE-}" in
(contains)
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --tags --exact-match HEAD ;;
esac 2>/dev/null)" ||
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
b="unknown"
b="($b)"
}
fi
local w=""
local i=""
local s=""
local u=""
local c=""
local p=""
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
c="BARE:"
else
b="GIT_DIR!"
fi
elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
git diff --no-ext-diff --quiet --exit-code || w="*"
if git rev-parse --quiet --verify HEAD >/dev/null; then
git diff-index --cached --quiet HEAD -- || i="+"
else
i="#"
fi
fi
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
u="%"
fi
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
fi
local f="$w$i$s$u"
printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
fi
}
dir=$(dirname $0)
source $dir/../git/git.plugin.zsh
source $dir/git-prompt.sh
function git_prompt_info() {
__git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
}
...@@ -61,6 +61,7 @@ exist_gh() { # [DIRECTORY] ...@@ -61,6 +61,7 @@ exist_gh() { # [DIRECTORY]
cd "$1" cd "$1"
name=$( git config user.name ) name=$( git config user.name )
ghuser=$( git config github.user ) ghuser=$( git config github.user )
repo=$1
git remote add origin git@github.com:${ghuser}/${repo}.git git remote add origin git@github.com:${ghuser}/${repo}.git
git push -u origin master git push -u origin master
......
...@@ -154,5 +154,6 @@ case "$words[1]" in ...@@ -154,5 +154,6 @@ case "$words[1]" in
_arguments \ _arguments \
$_command_args \ $_command_args \
'(--app)--app[the app name]' \ '(--app)--app[the app name]' \
'(--remote)--remote[the remote name]' \
&& return 0 && return 0
alias h='history'
function hs
{
history | grep $*
}
alias hsi='hs -i'
# To use: add a .jira-url file in the base of your project
# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
# .jira-url in the current directory takes precedence
#
# If you use Rapid Board, set:
#JIRA_RAPID_BOARD="yes"
# in you .zshrc
#
# Setup: cd to/my/project
# echo "https://name.jira.com" >> .jira-url
# Usage: jira # opens a new issue
# jira ABC-123 # Opens an existing issue
open_jira_issue () {
if [ -f .jira-url ]; then
jira_url=$(cat .jira-url)
elif [ -f ~/.jira-url ]; then
jira_url=$(cat ~/.jira-url)
elif [[ "x$JIRA_URL" != "x" ]]; then
jira_url=$JIRA_URL
else
echo "JIRA url is not specified anywhere."
return 0
fi
if [ -z "$1" ]; then
echo "Opening new issue"
`open $jira_url/secure/CreateIssue!default.jspa`
else
echo "Opening issue #$1"
if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
`open $jira_url/issues/$1`
else
`open $jira_url/browse/$1`
fi
fi
}
alias jira='open_jira_issue'
...@@ -170,7 +170,11 @@ _chef_environments_remote() { ...@@ -170,7 +170,11 @@ _chef_environments_remote() {
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
_chef_cookbooks_local() { _chef_cookbooks_local() {
(for i in $( grep cookbook_path $HOME/.chef/knife.rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done) local knife_rb="$HOME/.chef/knife.rb"
if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb"
fi
(for i in $( grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done)
} }
# This function extracts the available cookbook versions on the chef server # This function extracts the available cookbook versions on the chef server
......
#compdef artisan
# Laravel autocompletion
# Author: John Hamelink <john@johnhamelink.com>
#
# This plugin does the following:
# - Adds aliases and autocompletion for artisan
# - Adds aliases and autocompletion for bob
local curcontext="$curcontext" state line _opts _bundles ret=1
_arguments -C \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
_values "Artisan command" \
'session\:install[Create a session table]' \
'migrate[Manage Migrations]' \
'test[Run a test]' \
'route\:\:call[Call a route in the CLI]' \
'key\:\:generate[Generate a key]'
ret=0
;;
args)
case $line[1] in
migrate)
_values \
'install[Create the Laravel migration table' \
'make[Create a migration]' \
'rollback[Roll back to the last migration operation]' \
'reset[Roll back all migrations that have ever run]'
ret=0
;;
esac
;;
esac
return ret
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