From b2cc9a0366b5650eaf896599cb4b3ec9f0cf6b8f Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Tue, 2 Jun 2015 19:27:51 +0100 Subject: [PATCH] Added gitflow --- bash_aliases | 1 + bash_functions | 3 + bash_profile | 1 - bashrc | 7 +- git-flow-completion.bash | 225 +++++++++++++++++++++++++++++++++++++++ install.sh | 2 +- 6 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 bash_functions create mode 100644 git-flow-completion.bash diff --git a/bash_aliases b/bash_aliases index e34a809..939388e 100644 --- a/bash_aliases +++ b/bash_aliases @@ -5,6 +5,7 @@ alias djshell="python manage.py shell_plus --use-pythonrc --ipython" alias dbshell="python manage.py dbshell" alias djmigrate="python manage.py schemamigration spa --auto" alias dss="cd ~/Dropbox/development/deepsouthsounds.com/dss.api && workon dssapi" +alias pgdo="sudo -u postgres" alias reloadbashrc="source ~/.bashrc" alias rmdb="find . -name \*\'s\ conflicted\ copy\ \* -exec rm {} \;" diff --git a/bash_functions b/bash_functions new file mode 100644 index 0000000..f0d9204 --- /dev/null +++ b/bash_functions @@ -0,0 +1,3 @@ +function pips() { + echo $'\n'$1 >> requirements.txt; pip install $1 +} diff --git a/bash_profile b/bash_profile index 47809eb..0ca279a 100644 --- a/bash_profile +++ b/bash_profile @@ -1,2 +1 @@ - [ -s "/home/fergalm/.kre/kvm/kvm.sh" ] && . "/home/fergalm/.kre/kvm/kvm.sh" # Load kvm diff --git a/bashrc b/bashrc index 88399a9..c71e6df 100644 --- a/bashrc +++ b/bashrc @@ -113,6 +113,11 @@ if ! shopt -oq posix; then fi fi +# Include functions file +if [ -f ~/.bash_functions ]; then + source ~/.bash_functions +fi + export ANDROID_SDK=/opt/android-sdk-linux/ export PATH=$PATH:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools/ @@ -124,7 +129,7 @@ export WORKON_HOME=~/.virtualenvs . /usr/local/bin/virtualenvwrapper.sh . ~/dotfiles/z.sh source ~/.bash_prompt - +source ~/dotfiles/git-flow-completion.bash export HISTCONTROL=ignoredups:erasedups # no duplicate entries export HISTSIZE=100000 # big big history diff --git a/git-flow-completion.bash b/git-flow-completion.bash new file mode 100644 index 0000000..6ee517a --- /dev/null +++ b/git-flow-completion.bash @@ -0,0 +1,225 @@ +#!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) 2010-2015 [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 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 'hotfix')" + return + ;; + publish) + __gitcomp "$(comm -23 <(__git_flow_list_branches 'hotfix') <(__git_flow_list_remote_branches 'hotfix'))" + return + ;; + track) + __gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'hotfix') <(__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 --no-color 2> /dev/null | tr -d ' |*' | grep --color=never "^$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 --no-color -r 2> /dev/null | sed "s/^ *//g" | grep --color=never "^$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 diff --git a/install.sh b/install.sh index ca206bd..b30ba33 100755 --- a/install.sh +++ b/install.sh @@ -6,7 +6,7 @@ h dir=~/dotfiles # dotfiles directory olddir=~/dotfiles_old # old dotfiles backup directory -files="bashrc bash_aliases bash_profile bash_prompt" # list of files/folders to symlink in homedir +files="bashrc bash_aliases bash_profile bash_prompt bash_functions" # list of files/folders to symlink in homedir ##########