flow completion added
This commit is contained in:
parent
fad03e8e41
commit
d7d5d4b5d9
3 changed files with 2951 additions and 9 deletions
2726
bash/bash_completion/git
Normal file
2726
bash/bash_completion/git
Normal file
File diff suppressed because it is too large
Load diff
17
bash/bashrc
17
bash/bashrc
|
|
@ -31,14 +31,14 @@ export EDITOR=/usr/bin/mvim
|
||||||
|
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
if [ -x /usr/bin/dircolors ]; then
|
||||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
alias ls='ls --color=auto'
|
|
||||||
#alias dir='dir --color=auto'
|
#alias dir='dir --color=auto'
|
||||||
#alias vdir='vdir --color=auto'
|
#alias vdir='vdir --color=auto'
|
||||||
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
alias fgrep='fgrep --color=auto'
|
|
||||||
alias egrep='egrep --color=auto'
|
|
||||||
fi
|
fi
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
alias grep='grep --color'
|
||||||
|
alias fgrep='fgrep --color'
|
||||||
|
alias egrep='egrep --color'
|
||||||
|
|
||||||
# MacPorts Installer addition on 2012-07-11_at_04:34:47: adding an appropriate PATH variable for use with MacPorts.
|
# MacPorts Installer addition on 2012-07-11_at_04:34:47: adding an appropriate PATH variable for use with MacPorts.
|
||||||
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
|
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
|
||||||
|
|
@ -79,15 +79,14 @@ export PATH=${PATH}:/usr/local/pgsql/bin
|
||||||
export PGDATA=/usr/local/pgsql/data
|
export PGDATA=/usr/local/pgsql/data
|
||||||
|
|
||||||
|
|
||||||
if [ -f /opt/local/etc/bash_completion ]; then
|
if [ -f /opt/local/etc/bash_completion.d/git ]; then
|
||||||
. /opt/local/etc/bash_completion.d/git
|
source /opt/local/etc/bash_completion.d/git
|
||||||
export GIT_PS1_SHOWDIRTYSTATE=1
|
export GIT_PS1_SHOWDIRTYSTATE=1
|
||||||
export GIT_PS1_SHOWUPSTREAM=auto
|
export GIT_PS1_SHOWUPSTREAM=auto
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.git-flow-completion.bash ]; then
|
|
||||||
. ~/.git-flow-completion.bash
|
source ~/.git-flow-completion.bash
|
||||||
fi
|
|
||||||
|
|
||||||
#export PS1="$BLACK[ \u@$RED\h $GREEN\w$RED_BOLD\$(parse_git_branch)\$(parse_svn_branch)$BLACK ] "
|
#export PS1="$BLACK[ \u@$RED\h $GREEN\w$RED_BOLD\$(parse_git_branch)\$(parse_svn_branch)$BLACK ] "
|
||||||
|
|
||||||
|
|
|
||||||
217
bash/git-flow-completion.bash
Executable file
217
bash/git-flow-completion.bash
Executable file
|
|
@ -0,0 +1,217 @@
|
||||||
|
#!bash
|
||||||
|
#
|
||||||
|
# git-flow-completion
|
||||||
|
# ===================
|
||||||
|
#
|
||||||
|
# Bash completion support for [git-flow](http://github.com/nvie/gitflow)
|
||||||
|
#
|
||||||
|
# The contained completion routines provide support for completing:
|
||||||
|
#
|
||||||
|
# * git-flow init and version
|
||||||
|
# * feature, hotfix and release branches
|
||||||
|
# * remote feature, hotfix and release branch names
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Installation
|
||||||
|
# ------------
|
||||||
|
#
|
||||||
|
# To achieve git-flow completion nirvana:
|
||||||
|
#
|
||||||
|
# 0. Install git-completion.
|
||||||
|
#
|
||||||
|
# 1. Install this file. Either:
|
||||||
|
#
|
||||||
|
# a. Place it in a `bash-completion.d` folder:
|
||||||
|
#
|
||||||
|
# * /etc/bash-completion.d
|
||||||
|
# * /usr/local/etc/bash-completion.d
|
||||||
|
# * ~/bash-completion.d
|
||||||
|
#
|
||||||
|
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in
|
||||||
|
# your .bashrc:
|
||||||
|
#
|
||||||
|
# source ~/.git-flow-completion.sh
|
||||||
|
#
|
||||||
|
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant
|
||||||
|
# $command case in _git:
|
||||||
|
#
|
||||||
|
# flow) _git_flow ;;
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# The Fine Print
|
||||||
|
# --------------
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 [Justin Hileman](http://justinhileman.com)
|
||||||
|
#
|
||||||
|
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||||
|
|
||||||
|
_git_flow ()
|
||||||
|
{
|
||||||
|
local subcommands="init feature release hotfix support help version"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
init)
|
||||||
|
__git_flow_init
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
feature)
|
||||||
|
__git_flow_feature
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
release)
|
||||||
|
__git_flow_release
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
hotfix)
|
||||||
|
__git_flow_hotfix
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
support)
|
||||||
|
__git_flow_support
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_init ()
|
||||||
|
{
|
||||||
|
local subcommands="help"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_feature ()
|
||||||
|
{
|
||||||
|
local subcommands="list start finish publish track diff rebase checkout pull help"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
pull)
|
||||||
|
__gitcomp "$(__git_remotes)"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
checkout|finish|diff|rebase)
|
||||||
|
__gitcomp "$(__git_flow_list_branches 'feature')"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
publish)
|
||||||
|
__gitcomp "$(comm -23 <(__git_flow_list_branches 'feature') <(__git_flow_list_remote_branches 'feature'))"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
track)
|
||||||
|
__gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'feature') <(__git_flow_list_branches 'feature'))"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_release ()
|
||||||
|
{
|
||||||
|
local subcommands="list start finish track publish help"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
finish)
|
||||||
|
__gitcomp "$(__git_flow_list_branches 'release')"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
publish)
|
||||||
|
__gitcomp "$(comm -23 <(__git_flow_list_branches 'release') <(__git_flow_list_remote_branches 'release'))"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
track)
|
||||||
|
__gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'release') <(__git_flow_list_branches 'release'))"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_hotfix ()
|
||||||
|
{
|
||||||
|
local subcommands="list start finish help"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
finish)
|
||||||
|
__gitcomp "$(__git_flow_list_branches 'hotfix')"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_support ()
|
||||||
|
{
|
||||||
|
local subcommands="list start help"
|
||||||
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
|
if [ -z "$subcommand" ]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand" in
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_prefix ()
|
||||||
|
{
|
||||||
|
case "$1" in
|
||||||
|
feature|release|hotfix)
|
||||||
|
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_list_branches ()
|
||||||
|
{
|
||||||
|
local prefix="$(__git_flow_prefix $1)"
|
||||||
|
git branch 2> /dev/null | tr -d ' |*' | grep "^$prefix" | sed s,^$prefix,, | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_flow_list_remote_branches ()
|
||||||
|
{
|
||||||
|
local prefix="$(__git_flow_prefix $1)"
|
||||||
|
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||||
|
git branch -r 2> /dev/null | sed "s/^ *//g" | grep "^$origin/$prefix" | sed s,^$origin/$prefix,, | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
# alias __git_find_on_cmdline for backwards compatibility
|
||||||
|
if [ -z "`type -t __git_find_on_cmdline`" ]; then
|
||||||
|
alias __git_find_on_cmdline=__git_find_subcommand
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue