GithubHelp home page GithubHelp logo

gradle-tab-completion's Introduction

Build Status

A Gradle tab completion script for (git)Bash

Now also works in git-bash

Do you use gradle from the commandline and sometimes find yourself staring dreamily into the distance at the thought of just pressing tab to see which tasks you can execute?

Well now you can!

Edit:
Okay, well apparently someone had built this already, and gradle even made it repo-official: https://github.com/gradle/gradle-completion

I lost all motivation after I discovered my let's-google-if-someone-already-built-this skills where in need of some polishing, but as I found that the aforementioned official gradle-completion is untested and was a bit over the top for my taste, I decided to finish my own version anyway.

Usage

It is just autocompletion dummy. How did you think you where going to use it?

    $ ./gradlew c[TAB]
check                    clean                    connectedCheck           connectedInstrumentTest

Okay, here it starts getting interesting: sub-projects are now also supported...

    $ ./gradlew proj[TAB]
proj:check               proj:clean               proj:connectedCheck      proj:connectedInstrumentTest

...and of course: flags. Flags expecting files or paths just work like you'd expect them to.

    $ ./gradlew --p[TAB]
--parallel           --profile            --project-cache-dir  --project-dir        --project-prop

    $ ./gradlew --project-cache-dir [TAB]
dir1                dir2

Note on cache:

Results are cached on first run and completion is fast after that. Caches are invalidated by changes in your *.gradle scripts, so tasks that are added or removed are reflected instantly as well.

Installation

The easy way

Install in your user-home with something copy-past-able:

cd ~ #or whereever
curl https://raw.githubusercontent.com/meonlol/gradle-tab-completion/master/gradle-tab-completion.bash -o gradle-tab-completion.bash
chmod +x gradle-tab-completion.bash
LINE="source $(pwd)/gradle-tab-completion.bash"; [[ -e ~/.bash_profile ]] && echo $LINE >> ~/.bash_profile || echo $LINE >> ~/.bashrc

The 'correct' way

Download the script file and put it one of the standard locations for completion scripts:

  • /etc/bash_completion.d - for all users,
  • /usr/local/etc/bash_completion.d - for you
  • ~/bash_completion.d - Also for you, but grouped in a neat directory.

The script will then be automatically loaded.

Credit

This script was initially forked from this script by @nolanlawson. Also, after find out he'd already built this, I sometimes looked at what @eriwen did in his script.

gradle-tab-completion's People

Contributors

nolanlawson avatar ligi avatar

Stargazers

Nathan Arthur avatar wskplho avatar Florian Dreier avatar Karol Mierzejewski avatar dcampos avatar

Watchers

Stepan Herold avatar wskplho avatar  avatar Leon Schreuder avatar

Forkers

wskplho eaaltonen

gradle-tab-completion's Issues

Does not work nicely with custom build script names

The completion works fine if your root build script is either named build.gradle or its name is set via rootProject.buildFileName = '...' or rootProject.buildFileName = "..." (actually also rootProject.buildFileName = "...' and rootProject.buildFileName = '...", but those will not compile anyway) exactly like that.
You cannot use a variable for the name, you cannot leave out the spaces around the equals sign or add more, it has to be at the start of a line without any preceding whitespaces, and you cannot use other constructs to set the name that are perfectly legal. In my case I do it for all projects like this which of course also does not work:

def setBuildFileNameRecursively
setBuildFileNameRecursively = { it ->
it.buildFileName = "${it.name}.gradle"
it.children.each { setBuildFileNameRecursively it }
}
setBuildFileNameRecursively rootProject
It would be nice if the completion would not require some narrow range of modification options but simply work. Is it really necessary to determine the root project filename upfront? Can't you use -p instead of -b for the call and use the project dir as cache key instead of the build file?

@Vampire I've copied your Issue for my script if you don't mind. I want to make sure this is not a problem for mine as well.

Consecutive File-path completion is broken

If trying to reference a file when completing a gradle command, tab-completion no longer works.

E.g. ./gradlew -I ../[tab] to find an init script does not work.

Tested with Gradle 4.0, Bash 3.2.57(1)-release, MacOS 10.12.5

@tomdcc I copied this here if you don't mind.

[documentation]

Small documentation mistake, install misses chmod +x on newly downloaded file :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.