Debian Codegraph @

src/bibtexconv.bash-completion

raw
1 # shellcheck shell=bash
2 # ==========================================================================
3 # ____ _ _ _____ __ ______
4 # | __ )(_) |_|_ _|__\ \/ / ___|___ _ ____ __
5 # | _ \| | '_ \| |/ _ \ / | / _ \| '_ \ \ / /
6 # | |_) | | |_) | | __// \ |__| (_) | | | \ V /
7 # |____/|_|_.__/|_|\___/_/\_\____\___/|_| |_|\_/
8 #
9 # --- BibTeX Converter ---
10 # https://www.nntb.no/~dreibh/bibtexconv/
11 # ==========================================================================
12 #
13 # BibTeX Converter
14 # Copyright (C) 2010-2026 by Thomas Dreibholz
15 #
16 # This program is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #
29 # Contact: [email protected]
30
31
32 # ###### Bash completion for bibtexconv #####################################
33 _bibtexconv()
34 {
35 # Based on: https://www.benningtons.net/index.php/bash-completion/
36 local cur prev words cword
37 if type -t _comp_initialize >/dev/null; then
38 _comp_initialize || return
39 elif type -t _init_completion >/dev/null; then
40 _init_completion || return
41 else
42 # Manual initialization for older bash completion versions:
43 COMPREPLY=()
44 cur="${COMP_WORDS[COMP_CWORD]}"
45 # shellcheck disable=SC2034
46 prev="${COMP_WORDS[COMP_CWORD-1]}"
47 # shellcheck disable=SC2034,SC2124
48 words="${COMP_WORDS[@]}"
49 # shellcheck disable=SC2034
50 cword="${COMP_CWORD}"
51 fi
52
53 # ====== Parameters ======================================================
54 if [ "${cword}" -le 1 ] ; then
55 # BibTeX file names:
56 _filedir '@(bib)'
57 return
58 else
59 case "${prev}" in
60 # ====== BibTeX file ==============================================
61 -B | --export-to-bibtex)
62 _filedir '@(bib)'
63 return
64 ;;
65 # ====== XML file =================================================
66 -X | --export-to-xml)
67 _filedir '@(xml)'
68 return
69 ;;
70 # ====== Generic file or directory ================================
71 -b | --export-to-separate-bibtexs | \
72 -x | --export-to-separate-xmls)
73 _filedir '@(bib)'
74 return
75 ;;
76 # ====== Directory ================================================
77 -D | --store-downloads)
78 _filedir -d
79 return
80 ;;
81 # ====== Generic value ============================================
82 -s | --nbsp | \
83 -l | --linebreak | \
84 -m | --mapping)
85 return
86 ;;
87 *)
88 if [ "${cword}" -lt 1 ] ; then
89 # BibTeX file names:
90 _filedir '@(bib)'
91 return
92 fi
93 ;;
94 esac
95 fi
96
97 # ====== All options =====================================================
98 local opts="
99 -B
100 --export-to-bibtex
101 -b
102 -X
103 --export-to-xml
104 -x
105 --export-to-separate-xmls
106 -C
107 --export-to-custom
108 -D
109 --store-downloads
110 -m
111 --mapping
112 -s
113 --nbsp
114 -l
115 --linebreak
116 -n
117 --non-interactive
118 -U
119 --check-urls
120 -u
121 --only-check-new-urls
122 -w
123 --ignore-updates-for-html
124 -a
125 --add-url-command
126 -i
127 --skip-notes-with-isbn-and-issn
128 -I
129 --add-notes-with-isbn-and-issn
130 -q
131 --quiet
132 -h
133 --help
134 -v
135 --version
136 "
137 # shellcheck disable=SC2207
138 COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
139 return 0
140 }
141
142 complete -F _bibtexconv bibtexconv