| 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-odt ################################# |
| 33 |
_bibtexconv_odt() |
| 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 2 ] ; then |
| 55 |
# OpenDocument Text (ODT) file names: |
| 56 |
_filedir '@(odt)' |
| 57 |
return |
| 58 |
elif [ "${cword}" -le 3 ] ; then |
| 59 |
# BibTeX file names: |
| 60 |
_filedir '@(bib)' |
| 61 |
return |
| 62 |
elif [ "${cword}" -le 4 ] ; then |
| 63 |
# Export script names: |
| 64 |
_filedir '@(export)' |
| 65 |
return |
| 66 |
fi |
| 67 |
|
| 68 |
# ====== All options ===================================================== |
| 69 |
local opts=" |
| 70 |
" |
| 71 |
# shellcheck disable=SC2207 |
| 72 |
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) ) |
| 73 |
return 0 |
| 74 |
} |
| 75 |
|
| 76 |
complete -F _bibtexconv_odt bibtexconv-odt |