@@ -0,0 +1,84 @@
1+# shellcheck disable=SC2207
2+
3+_bat() {
4+ if [[ ${COMP_WORDS[1]-} == cache ]]; then
5+ case $3 in
6+ --source | --target)
7+ local IFS=$'\n'
8+ COMPREPLY=($(compgen -d -- "$2"))
9+ compopt -o filenames
10+ return 0
11+ ;;
12+ esac
13+ COMPREPLY=($(compgen -W "
14+ --build --clear --source --target --blank --help
15+ " -- "$2"))
16+ return 0
17+ fi
18+
19+ case $3 in
20+ -l | --language)
21+ local IFS=$'\n'
22+ COMPREPLY=($(compgen -W "$(
23+ "$1" --list-languages | while IFS=: read -r lang _; do
24+ printf "%s\n" "$lang"
25+ done
26+ )" -- "$2"))
27+ compopt -o filenames # for escaping
28+ return 0
29+ ;;
30+ -H | --highlight-line | --diff-context | --tabs | --terminal-width | \
31+ -m | --map-syntax | --style | --line-range | -h | --help | -V | \
32+ --version)
33+ # argument required but no completion available, or argument
34+ # causes an exit
35+ return 0
36+ ;;
37+ --file-name)
38+ local IFS=$'\n'
39+ COMPREPLY=($(compgen -f -- "$2"))
40+ compopt -o filenames
41+ return 0
42+ ;;
43+ --wrap)
44+ COMPREPLY=($(compgen -W "auto never character" -- "$2"))
45+ return 0
46+ ;;
47+ --color | --decorations | --paging)
48+ COMPREPLY=($(compgen -W "auto never always" -- "$2"))
49+ return 0
50+ ;;
51+ --italic-text)
52+ COMPREPLY=($(compgen -W "always never" -- "$2"))
53+ return 0
54+ ;;
55+ --pager)
56+ COMPREPLY=($(compgen -c -- "$2"))
57+ return 0
58+ ;;
59+ --theme)
60+ local IFS=$'\n'
61+ COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$2"))
62+ compopt -o filenames
63+ return 0
64+ ;;
65+ esac
66+
67+ if [[ $2 == -* ]]; then
68+ COMPREPLY=($(compgen -W "
69+ --show-all --plain --language --highlight-line
70+ --file-name --diff --diff-context --tabs --wrap
71+ --terminal-width --number --color --italic-text
72+ --decorations --paging --pager --map-syntax --theme
73+ --list-themes --style --line-range --list-languages
74+ --help --version
75+ " -- "$2"))
76+ return 0
77+ fi
78+
79+ local IFS=$'\n'
80+ COMPREPLY=($(compgen -f -- "$2"))
81+ compopt -o filenames
82+ ((COMP_CWORD == 1)) && COMPREPLY+=($(compgen -W cache -- "$2"))
83+
84+} && complete -F _bat {{PROJECT_EXECUTABLE}}