[tracker] cli: Improve bash completion script
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] cli: Improve bash completion script
- Date: Sun, 5 Jul 2015 15:08:23 +0000 (UTC)
commit 56569070dab3aaa2b2ab65367b7f6c2e984b2430
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jul 5 17:04:20 2015 +0200
cli: Improve bash completion script
We now autocomplete files where it applies (various -f/--file options,
tracker info) and '-' prefixed switches.
src/tracker/bash-completion/tracker | 36 ++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker/bash-completion/tracker b/src/tracker/bash-completion/tracker
index 8022b6a..12749cd 100644
--- a/src/tracker/bash-completion/tracker
+++ b/src/tracker/bash-completion/tracker
@@ -2,9 +2,39 @@
tracker_cmds()
{
- possible=`tracker | egrep " [a-z].* " | awk '{ print ($1) }'`
- local cur=${COMP_WORDS[COMP_CWORD]}
- COMPREPLY=( $(compgen -W "$possible" -- $cur) )
+ local cur prev words cword
+ _init_completion -s || return
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ if [[ $cword == 1 ]]; then
+ possible=`tracker | egrep " [a-z].* " | awk '{ print ($1) }'`
+ COMPREPLY=( $(compgen -W "$possible" -- $cur) )
+ return 0;
+ fi
+
+ case $prev in
+ -h|--help)
+ return 0;
+ ;;
+ info|-f|--file)
+ if [[ $cur != -* ]]; then
+ _filedir
+ return 0;
+ fi
+ ;;
+ *)
+ ;;
+ esac
+
+ if [[ $cword -lt 2 ]]; then
+ return 0;
+ fi
+
+ if [[ -z $cur ]] || [[ $cur == -* ]]; then
+ possible=`${words[0]} ${words[1]} -h | egrep "^ *-" | sed "s/^ *//" | sed "s/ [^-].*//" | sed
"s/,/\n/g" | sed "s/=.*//"`
+ COMPREPLY=( $(compgen -W "$possible" -- $cur) )
+ fi
}
complete -F tracker_cmds tracker
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]