-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_completion.bash
More file actions
36 lines (30 loc) · 1.01 KB
/
test_completion.bash
File metadata and controls
36 lines (30 loc) · 1.01 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
#!/usr/bin/env bash
set -euo pipefail
# Load completion environment
# Try Git Bash (Windows) paths first, then fall back to Linux paths
load_completion() {
local git_bash_completion="/mingw64/share/git/completion/git-completion.bash"
local linux_bash_completion="/usr/share/bash-completion/bash_completion"
local linux_git_completion="/usr/share/bash-completion/completions/git"
if [[ -f "$git_bash_completion" ]]; then
# Git Bash on Windows bundles git completion directly
source "$git_bash_completion"
elif [[ -f "$linux_bash_completion" ]]; then
source "$linux_bash_completion"
[[ -f "$linux_git_completion" ]] && source "$linux_git_completion"
else
echo "ERROR: Could not find bash-completion files." >&2
exit 1
fi
}
load_completion
source ./autocompletion.bash
# Simulate:
# git pad e<TAB>
echo '- Testing git pad e<TAB>'
COMP_WORDS=(git pad e)
COMP_CWORD=2
COMP_LINE="git pad e"
COMP_POINT=${#COMP_LINE}
_git_pad
printf '%s\n' "${COMPREPLY[@]}"