From 6a1bf8d11430fea80864bd0fef46210143d91407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 6 Feb 2015 20:38:39 +0200 Subject: [PATCH] synclient: New completion --- completions/Makefile.am | 1 + completions/synclient | 24 ++++++++++++++++++++++++ test/completion/synclient.exp | 1 + test/lib/completions/synclient.exp | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 completions/synclient create mode 100644 test/completion/synclient.exp create mode 100644 test/lib/completions/synclient.exp diff --git a/completions/Makefile.am b/completions/Makefile.am index 5c8f61c6..d4851434 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -348,6 +348,7 @@ bashcomp_DATA = 2to3 \ _svnadmin \ _svnlook \ sync_members \ + synclient \ sysbench \ sysctl \ tar \ diff --git a/completions/synclient b/completions/synclient new file mode 100644 index 00000000..55c8ba82 --- /dev/null +++ b/completions/synclient @@ -0,0 +1,24 @@ +# bash completion for synclient(1) -*- shell-script -*- + +_synclient() +{ + local cur prev words cword split + _init_completion -n = || return + + case $prev in + -\?|-h|-V) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + elif [[ $cur != *=?* ]]; then + COMPREPLY=( $( compgen -S = -W '$( $1 -l 2>/dev/null | \ + awk "/^[[:space:]]/ { print \$1 }" )' -- "$cur" ) ) + compopt -o nospace + fi +} && +complete -F _synclient synclient + +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/synclient.exp b/test/completion/synclient.exp new file mode 100644 index 00000000..9a277096 --- /dev/null +++ b/test/completion/synclient.exp @@ -0,0 +1 @@ +assert_source_completions synclient diff --git a/test/lib/completions/synclient.exp b/test/lib/completions/synclient.exp new file mode 100644 index 00000000..434e98f2 --- /dev/null +++ b/test/lib/completions/synclient.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "synclient " +sync_after_int + + +teardown