-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-completion.sh
More file actions
executable file
·99 lines (85 loc) · 3.36 KB
/
setup-completion.sh
File metadata and controls
executable file
·99 lines (85 loc) · 3.36 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
# Setup bash completion for install-agents command
# This script sets up autocompletion for the install-agents command
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPLETION_FILE="$SCRIPT_DIR/install-agents-completion.bash"
# Colors for output
if [[ -t 1 ]]; then
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
else
GREEN=''
BLUE=''
YELLOW=''
NC=''
fi
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
# Check if completion file exists
if [[ ! -f "$COMPLETION_FILE" ]]; then
echo "Error: Completion file not found at $COMPLETION_FILE"
exit 1
fi
print_info "Setting up bash completion for install-agents..."
# Option 1: Source directly in current session
print_info "Loading completion for current session..."
source "$COMPLETION_FILE"
print_success "Completion loaded for current session"
# Option 2: Add to user's bashrc for persistence
BASHRC="$HOME/.bashrc"
COMPLETION_LINE="source \"$COMPLETION_FILE\""
if [[ -f "$BASHRC" ]]; then
if ! grep -q "install-agents-completion.bash" "$BASHRC"; then
print_info "Adding completion to ~/.bashrc for future sessions..."
echo "" >> "$BASHRC"
echo "# install-agents bash completion" >> "$BASHRC"
echo "$COMPLETION_LINE" >> "$BASHRC"
print_success "Added completion to ~/.bashrc"
print_info "Restart your terminal or run 'source ~/.bashrc' to enable completion in new sessions"
else
print_warning "Completion already configured in ~/.bashrc"
fi
else
print_warning "~/.bashrc not found, completion will only work in current session"
fi
# Option 3: System-wide installation (if possible)
if [[ -w /etc/bash_completion.d/ ]] 2>/dev/null; then
print_info "System completion directory is writable, installing system-wide..."
sudo cp "$COMPLETION_FILE" /etc/bash_completion.d/install-agents
print_success "Installed system-wide completion"
elif [[ -d /usr/local/etc/bash_completion.d/ ]] && [[ -w /usr/local/etc/bash_completion.d/ ]] 2>/dev/null; then
print_info "Installing to /usr/local/etc/bash_completion.d/..."
cp "$COMPLETION_FILE" /usr/local/etc/bash_completion.d/install-agents
print_success "Installed local system completion"
else
print_warning "No system completion directory available or not writable"
fi
echo
print_success "Setup complete! Try typing 'install-agents <TAB>' to test completion"
echo
print_info "🎯 NEW DEFAULTS (Improved UX):"
echo " • Symlink mode enabled by default (was copy mode)"
echo " • Current directory as target (was explicit path required)"
echo " • Force mode enabled (was disabled)"
echo
print_info "Available completions:"
echo " • Command options: --help, --symlink, --profile, etc."
echo " • Profile names: development-team, core, backend-focus, etc."
echo " • Agent names: code-reviewer, debugger, test-automator, etc."
echo " • Directory paths for target projects"
echo
print_info "Examples to test (NEW simplified defaults):"
echo " install-agents <TAB> # Show agent names for current directory"
echo " install-agents --profile <TAB> # Show available profiles"
echo " install-agents --<TAB> # Show all options"
echo " install-agents --project /path/<TAB> # Complete directory paths"