diff --git a/lib/cli.js b/lib/cli.js index 2644139..566a691 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -14,8 +14,6 @@ if (process.env.TABTAB_DEBUG) { flags: 'a+' }); - string replace -r "/.*" "" -- $location - set location (string split "/" -- $location)[1] debug.log = (...args) => { args = args.map(arg => { if (typeof arg === 'string') return arg; @@ -30,6 +28,7 @@ if (argv[0] === 'completion' && !env.complete) { return console.log('do nothing'); } +console.error(env); if (argv[0] === 'completion' && env.complete) { if (/^--/.test(env.prev)) { tabtab.log(['--help', '--foo', '--bar'], env); @@ -37,7 +36,7 @@ if (argv[0] === 'completion' && env.complete) { } if (env.prev === 'tabtab') { - tabtab.log(['someCommand', 'anotherOne'], env); + tabtab.log(['someCommand', 'anotherOne', 'generator:app', 'generator:view'], env); return; } @@ -50,4 +49,9 @@ if (argv[0] === 'completion' && env.complete) { tabtab.log(['is', 'this', 'just', 'fantasy'], env); return; } + + if (env.prev === 'generator') { + tabtab.log(['generator\:app', 'generator\:view', 'generator\:foo', 'generator\:meow'], env); + return; + } } diff --git a/package.json b/package.json index c0a3e81..6d652b6 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "watch": "npm-watch", "prettier": "prettier -l '{lib,test}/**/*.js'", "quick-test": "DEBUG='tabtab*' node test/fixtures/installer-install.js", - "bash-quick-test": "DEBUG=tabtab* COMP_CWORD='2' COMP_LINE='tabtab foo' COMP_POINT='10' tabtab completion -- tabtab foo" + "bash-quick-test": "DEBUG=tabtab* COMP_CWORD='2' COMP_LINE='tabtab foo' COMP_POINT='10' tabtab completion -- tabtab foo", + "just:a:test": "echo just a test", + "just:a:test2": "echo just a test" }, "watch": { "test": "{lib,test}/**/*.js" diff --git a/scripts/bash.sh b/scripts/bash.sh index f2d85fe..41feeb5 100644 --- a/scripts/bash.sh +++ b/scripts/bash.sh @@ -3,7 +3,7 @@ if type complete &>/dev/null; then _{pkgname}_completion () { local words cword if type _get_comp_words_by_ref &>/dev/null; then - _get_comp_words_by_ref -n = -n @ -w words -i cword + _get_comp_words_by_ref -n = -n @ -n : -w words -i cword else cword="$COMP_CWORD" words=("${COMP_WORDS[@]}") @@ -16,6 +16,9 @@ if type complete &>/dev/null; then {completer} completion -- "${words[@]}" \ 2>/dev/null)) || return $? IFS="$si" + if type __ltrim_colon_completions &>/dev/null; then + __ltrim_colon_completions "${words[cword]}" + fi } complete -o default -F _{pkgname}_completion {pkgname} fi