aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-08-29 09:19:15 -0400
committerGitHub <noreply@github.com>2016-08-29 09:19:15 -0400
commit4696456fed668bcce279ecf28ae02ee43d32f741 (patch)
tree9ba1028a0c479aad812870dc349b44e1d299627b
parent60e50aa8588c8c91e3b9a0e0d3ecf9195a0665fa (diff)
parent36ae0d245f6103956cf3577afa403abc956f23e5 (diff)
downloadcbt-4696456fed668bcce279ecf28ae02ee43d32f741.tar.gz
cbt-4696456fed668bcce279ecf28ae02ee43d32f741.tar.bz2
cbt-4696456fed668bcce279ecf28ae02ee43d32f741.zip
Merge pull request #211 from cvogt/completions
Completions
-rw-r--r--README.md16
-rwxr-xr-xcbt1
-rwxr-xr-xshell-integration/cbt-completions.bash13
3 files changed, 30 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7a1174e..2f2134b 100644
--- a/README.md
+++ b/README.md
@@ -176,3 +176,19 @@ solution could be code generating traits at build-time and mixing them
in ad-hoc. It's a build-tool after all. Build-time code-generation and
class loading is not rocket science. But there may be simpler solutions
for the cases at hand. And they are edge cases anyways.
+
+Bash completions
+----------------
+To auto-complete cbt task names in bash do this:
+
+```
+mkdir ~/.bash_completion.d/
+cp shell-integration/cbt-completions.bash ~/.bash_completion.d/
+```
+
+Add this to you .bashrc
+```
+for f in ~/.bash_completion.d/*; do
+ source $f
+done
+```
diff --git a/cbt b/cbt
index 63b272e..5751e69 100755
--- a/cbt
+++ b/cbt
@@ -7,6 +7,7 @@
# - reduce code size by moving more of this into type-checked Java/Scala code (if possible without performance loss).
# - reduction of dependencies
# - performance improvements
+shopt -qs extglob
seconds() {
date +"%s"
diff --git a/shell-integration/cbt-completions.bash b/shell-integration/cbt-completions.bash
new file mode 100755
index 0000000..c591321
--- /dev/null
+++ b/shell-integration/cbt-completions.bash
@@ -0,0 +1,13 @@
+#!/bin/bash
+__cbt()
+{
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="$(cbt usage)"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+}
+
+complete -F __cbt cbt