2009-11-18 00:23:42 +01:00
|
|
|
# Bash completion for notmuch
|
2009-10-25 06:28:22 +01:00
|
|
|
#
|
|
|
|
# Copyright © 2009 Carl Worth
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see http://www.gnu.org/licenses/ .
|
|
|
|
#
|
|
|
|
# Author: Carl Worth <cworth@cworth.org>
|
|
|
|
#
|
|
|
|
# Based on "notmuch help" as follows:
|
|
|
|
#
|
|
|
|
# Usage: notmuch <command> [args...]
|
|
|
|
#
|
|
|
|
# Where <command> and [args...] are as follows:
|
|
|
|
#
|
|
|
|
# setup
|
|
|
|
#
|
|
|
|
# new
|
|
|
|
#
|
2009-11-18 10:29:19 +01:00
|
|
|
# search [options] <search-term> [...]
|
2009-10-25 06:28:22 +01:00
|
|
|
#
|
2009-11-18 10:29:19 +01:00
|
|
|
# show <search-terms>
|
|
|
|
#
|
|
|
|
# reply <search-terms>
|
|
|
|
#
|
|
|
|
# tag +<tag>|-<tag> [...] [--] <search-terms> [...]
|
2009-10-25 06:28:22 +01:00
|
|
|
#
|
|
|
|
# dump [<filename>]
|
|
|
|
#
|
|
|
|
# restore <filename>
|
2009-11-18 10:29:19 +01:00
|
|
|
#
|
|
|
|
# help [<command>]
|
2009-10-25 06:28:22 +01:00
|
|
|
|
|
|
|
_notmuch()
|
|
|
|
{
|
2009-11-19 03:14:52 +01:00
|
|
|
local current previous commands help_options
|
2009-10-25 06:28:22 +01:00
|
|
|
|
2009-11-19 03:14:52 +01:00
|
|
|
previous=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
current="${COMP_WORDS[COMP_CWORD]}"
|
2009-11-18 10:29:19 +01:00
|
|
|
|
2009-11-19 03:14:52 +01:00
|
|
|
commands="setup new search show reply tag dump restore help"
|
2009-11-18 10:29:19 +01:00
|
|
|
help_options="setup new search show reply tag dump restore search-terms"
|
2009-10-25 06:28:22 +01:00
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
|
2009-11-19 02:58:42 +01:00
|
|
|
if [[ "$COMP_CWORD" == "1" ]]; then
|
2009-11-19 03:12:59 +01:00
|
|
|
COMPREPLY=( $(compgen -W "${commands}" -- ${current}) )
|
2009-10-25 06:28:22 +01:00
|
|
|
fi
|
2009-11-18 10:29:19 +01:00
|
|
|
|
2009-11-19 03:14:52 +01:00
|
|
|
if [[ $previous = "help" && "$COMP_CWORD" == "2" ]]; then
|
2009-11-19 03:12:59 +01:00
|
|
|
COMPREPLY=( $(compgen -W "${help_options}" -- ${current}) )
|
2009-11-18 10:29:19 +01:00
|
|
|
fi
|
2009-10-25 06:28:22 +01:00
|
|
|
}
|
|
|
|
complete -o default -o bashdefault -F _notmuch notmuch
|