From 995dd04d24117c85949efadefbae2dda63e5dfff Mon Sep 17 00:00:00 2001 From: tbhaxor Date: Sun, 24 Feb 2019 21:47:12 +0530 Subject: [PATCH] added main dart completion --- completion/available/dart.completion.bash | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 completion/available/dart.completion.bash diff --git a/completion/available/dart.completion.bash b/completion/available/dart.completion.bash new file mode 100644 index 00000000..d2c2d8d2 --- /dev/null +++ b/completion/available/dart.completion.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +# ------------------------------------ +# Original Credits : https://github.com/claudiodangelis/dart-bash_completion +# ------------------------------------ +if command -v dart > /dev/null; then + __dart() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + # Options + opts="--help --checked --package-root --version" + + if [[ ${cur} == -* ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + elif [[ ${prev} != *.dart ]] ; then + local dart_scripts=$(for d in `ls -1 *.dart 2>/dev/null`; do echo ${d}; done) + COMPREPLY=( $(compgen -W "${dart_scripts}" -- ${cur}) ) + else + COMPREPLY=() + return 0 + fi + } + + complete -o default -F __dart dart + +fi \ No newline at end of file