-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathidoit.bash-completion
45 lines (39 loc) · 1.59 KB
/
idoit.bash-completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
## Copyright (C) 2016-18 Benjamin Heisig
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU Affero 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 Affero General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
_idoit_command() {
local cur options commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
options="-c -h --config --help --version"
commands="init status read show search random nextip fixip help categories types"
case "$prev" in
read)
local path=`idoit read $2 2> /dev/null | sed ':a;{N;s/\n/ /};ba'`
COMPREPLY=( $( compgen -W "$path" -- $cur ) )
#local files=( $(idoit read $2 2> /dev/null) )
#local files=("/tmp/$2"*)
#[[ -e ${files[0]} ]] && COMPREPLY=( "${files[@]##*/}" )
return 0
;;
esac
case "$cur" in
-*) COMPREPLY=( $( compgen -W "${options}" -- $cur ) );;
*) COMPREPLY=( $( compgen -W "${commands}" -- $cur ) );;
esac
return 0
}
complete -F _idoit_command idoit