-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdheaders.bash_completion
More file actions
53 lines (46 loc) · 1.3 KB
/
Copy pathmdheaders.bash_completion
File metadata and controls
53 lines (46 loc) · 1.3 KB
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
46
47
48
49
50
51
52
53
# Bash completion for mdheaders
# https://github.com/Open-Technology-Foundation/mdheaders
#
# Installation:
# System-wide: sudo cp mdheaders.bash_completion /etc/bash_completion.d/mdheaders
# User-only: cp mdheaders.bash_completion ~/.local/share/bash-completion/completions/mdheaders
_mdheaders() {
local cur prev words cword
_init_completion || return
local commands="upgrade up downgrade down normalize norm help"
local options="-l --levels -s --start-level -o --output -i --in-place -b --backup --skip-errors --stop-on-error -q --quiet -v --verbose -V --version -h --help"
# First argument: complete commands
if ((cword == 1)); then
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
return
fi
# After -o or --output: complete any file
case "$prev" in
-o|--output)
_filedir
return
;;
-l|--levels|-s|--start-level)
# Numeric argument expected, no completion
COMPREPLY=()
return
;;
-b|--backup)
# Optional suffix, no completion
COMPREPLY=()
return
;;
esac
# Options or markdown files
case "$cur" in
-*)
COMPREPLY=($(compgen -W "$options" -- "$cur"))
;;
*)
# Complete markdown files
_filedir '@(md|markdown|mkd|mdown)'
;;
esac
}
complete -F _mdheaders mdheaders
#fin