-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetree-completion.bash
More file actions
36 lines (29 loc) · 1005 Bytes
/
Copy pathdetree-completion.bash
File metadata and controls
36 lines (29 loc) · 1005 Bytes
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
# Bash completion script for detree
# Install: sudo cp detree-completion.bash /etc/bash_completion.d/detree
# Or: source detree-completion.bash
_detree_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Main options
opts="--remove-digits --allow-empty-folders --help --version"
# If current word starts with -, show options
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# Complete filenames for first argument (input file)
if [[ ${COMP_CWORD} -eq 1 ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
fi
# Complete directories for second argument (output dir)
if [[ ${COMP_CWORD} -eq 2 ]]; then
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
fi
}
complete -F _detree_completion detree
# Also support the Python script name
complete -F _detree_completion d2c2_cli.py