-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_completion
More file actions
executable file
·50 lines (43 loc) · 1.46 KB
/
bash_completion
File metadata and controls
executable file
·50 lines (43 loc) · 1.46 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
#!/usr/bin/env bash
# SENTINEL Bash Completion Loader
# Recursively loads all completion files from the completion directories
# Function to load completion files from a directory recursively
load_completions_recursive() {
local dir="$1"
local debug="${2:-0}" # 0=quiet, 1=debug output
if [[ "$debug" == "1" ]]; then
echo "DEBUG: Loading completion files from $dir"
fi
# First, load files in the current directory
if [[ -d "$dir" ]]; then
for bashcomp in "$dir"/*; do
if [[ -f "$bashcomp" && -r "$bashcomp" ]]; then
[[ "$debug" == "1" ]] && echo "DEBUG: Loading completion file $bashcomp"
source "$bashcomp"
fi
done
# Then recursively process subdirectories
for subdir in "$dir"/*; do
if [[ -d "$subdir" ]]; then
[[ "$debug" == "1" ]] && echo "DEBUG: Processing subdirectory $subdir"
load_completions_recursive "$subdir" "$debug"
fi
done
else
[[ "$debug" == "1" ]] && echo "DEBUG: Directory $dir does not exist or is not readable"
fi
}
# Load the system-wide bash completion if available
if [[ -f /etc/bash_completion && -r /etc/bash_completion ]]; then
# Only source if not already loaded to avoid duplication
if ! type -t _completion_loader >/dev/null 2>&1; then
source /etc/bash_completion
fi
fi
# Load all completion files recursively from user directory
if [[ -d "${HOME}/.bash_completion.d" ]]; then
load_completions_recursive "${HOME}/.bash_completion.d"
fi
# Cleanup
unset -f load_completions_recursive
unset bashcomp