Source

shared zshrc / zshrc_grails_compinstall

Full commit

_property_value() {
    grep $1 application.properties | sed -E 's/(.*)=(.*)$/\2/'
}

_grails_version() {
	_property_value app.grails.version
}

_grails_project_name() {
    _property_value app.name
}

_grails_script_dirs() {
	local SCRIPT_DIRS="$GRAILS_HOME/scripts ~/.grails/scripts ./scripts"
	for PLUGIN_DIR in ~/.grails/$(_grails_version)/projects/$(_grails_project_name)/plugins/*/scripts; do
		SCRIPT_DIRS="$SCRIPT_DIRS $PLUGIN_DIR"
	done
	echo $SCRIPT_DIRS
}

_grails_scripts() {	
	for D in $(_grails_script_dirs); do
		if [ -d $D ]
			then ls -1 $D/* | grep -e ".groovy$" | sed -E 's/(.*)\/(.*)\.groovy$/\2/' | sed -E 's/([A-Z])/-\1/g' | sed -E 's/^-//' | tr "[:upper:]" "[:lower:]"
		fi
	done | sort | uniq | grep -vE "^_" 	
}

_grails_tests() {
	if [ -d test ] 
		then ls -1 test/**/*Tests.* | sed -E 's/(test\/[^\/]*\/)(.*)(Tests.*)/\2/' | uniq | tr \/ .
    fi	
}

_grails() {
	if (( CURRENT == 2 )); then
		scripts=( $(_grails_scripts) )
		_sep_parts scripts
    else
		tests=( $(_grails_tests) )
       	_multi_parts . tests
   	fi
}

compdef _grails grails

_hg_commands() {
	hg debugcomplete
}

_hg_branches() {
    hg branches | sed -E 's/(.*) .*/\1/g'
    hg bookmarks | sed -E 's/(.*) .*/\1/g'
}

_hg() {
	if (( CURRENT == 2 )); then
		hg_commands=( $(_hg_commands) )
		_sep_parts hg_commands
    else
		hg_branches=( $(_hg_branches) )
       	_sep_parts hg_branches
   	fi
}

compdef _hg hg

# speed up git autocompletion, don't care about remote files just local branches and files, otherwise have to hit ctrl-c to get completion to short circuit before heat death of universe
__git_files () { 
    _wanted files expl 'local files' _files
}