summaryrefslogtreecommitdiff
path: root/data/bash_completion.tpl
diff options
context:
space:
mode:
Diffstat (limited to 'data/bash_completion.tpl')
-rw-r--r--data/bash_completion.tpl62
1 files changed, 62 insertions, 0 deletions
diff --git a/data/bash_completion.tpl b/data/bash_completion.tpl
new file mode 100644
index 000000000..6d7e17215
--- /dev/null
+++ b/data/bash_completion.tpl
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# This script enables bash autocompletion for pandoc. To enable
+# bash completion, add this to your .bashrc:
+# eval "$(pandoc --bash-completion)"
+
+_pandoc()
+{
+ local cur prev opts lastc informats outformats datadir
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ # These should be filled in by pandoc:
+ opts="%s"
+ informats="%s"
+ outformats="%s"
+ datadir="%s"
+
+ case "${prev}" in
+ --from|-f|--read|-r)
+ COMPREPLY=( $(compgen -W "${informats}" -- ${cur}) )
+ return 0
+ ;;
+ --to|-t|--write|-w|-D|--print-default-template)
+ COMPREPLY=( $(compgen -W "${outformats}" -- ${cur}) )
+ return 0
+ ;;
+ --email-obfuscation)
+ COMPREPLY=( $(compgen -W "references javascript none" -- ${cur}) )
+ return 0
+ ;;
+ --latex-engine)
+ COMPREPLY=( $(compgen -W "pdflatex lualatex xelatex" -- ${cur}) )
+ return 0
+ ;;
+ --print-default-data-file)
+ COMPREPLY=( $(compgen -W "reference.odt reference.docx $(find ${datadir} | sed -e 's/.*\/data\///')" -- ${cur}) )
+ return 0
+ ;;
+ --highlight-style)
+ COMPREPLY=( $(compgen -W "pygments tango espresso zenburn kate monochrome haddock" -- ${cur}) )
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+
+ case "${cur}" in
+ -*)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ *)
+ COMPREPLY=( $(compgen -f ${cur}) )
+ return 0
+ ;;
+ esac
+
+}
+
+complete -F _pandoc pandoc