-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (88 loc) · 2.74 KB
/
install.sh
File metadata and controls
executable file
·105 lines (88 loc) · 2.74 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
100
101
102
103
104
105
#!/bin/bash
# Installation script for CodeSelect - no admin privileges required
set -e
echo "Installing CodeSelect..."
# Determine installation directory
USER_BIN="$HOME/.local/bin"
mkdir -p "$USER_BIN"
# Create CodeSelect file
CODESELECT_PATH="$USER_BIN/codeselect"
# Download or create the file
echo "Downloading CodeSelect..."
curl -fsSL https://raw.githubusercontent.com/maynetee/codeselect/main/codeselect.py -o "$CODESELECT_PATH" 2>/dev/null || {
# If curl fails (e.g., GitHub URL not yet available), copy from the local file
if [ -f "codeselect.py" ]; then
cp "codeselect.py" "$CODESELECT_PATH"
else
echo "Error: Cannot download or find codeselect.py"
exit 1
fi
}
# Make the script executable
chmod +x "$CODESELECT_PATH"
# Check if the directory is in PATH
if [[ ":$PATH:" != *":$USER_BIN:"* ]]; then
# Determine shell config file
SHELL_CONFIG=""
if [[ "$SHELL" == *"zsh"* ]]; then
SHELL_CONFIG="$HOME/.zshrc"
elif [[ "$SHELL" == *"bash"* ]]; then
if [[ "$(uname)" == "Darwin" ]] && [[ ! -f "$HOME/.bashrc" ]]; then
SHELL_CONFIG="$HOME/.bash_profile"
else
SHELL_CONFIG="$HOME/.bashrc"
fi
else
SHELL_CONFIG="$HOME/.profile"
fi
# Add to PATH
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$SHELL_CONFIG"
echo "Added $USER_BIN to your PATH in $SHELL_CONFIG"
echo "To use immediately, run: source $SHELL_CONFIG"
fi
echo "
Installation complete!
Usage:
codeselect # Analyze current directory
codeselect /path/to/project # Analyze a specific directory
codeselect --help # Show help
CodeSelect is now installed at: $CODESELECT_PATH
"
# Try to add tab completion for bash
if [[ "$SHELL" == *"bash"* ]]; then
COMPLETION_FILE="$HOME/.local/share/bash-completion/completions"
mkdir -p "$COMPLETION_FILE"
cat > "$COMPLETION_FILE/codeselect" << 'EOF'
_codeselect_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Basic options
opts="--format --output --skip-selection --no-clipboard --version --help"
# Handle specific options
case "${prev}" in
--format|-f)
COMPREPLY=( $(compgen -W "txt md llm" -- "${cur}") )
return 0
;;
--output|-o)
COMPREPLY=( $(compgen -f -- "${cur}") )
return 0
;;
*)
;;
esac
# Complete options or directories
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
else
COMPREPLY=( $(compgen -d -- "${cur}") )
fi
return 0
}
complete -F _codeselect_completion codeselect
EOF
echo "Added bash tab completion for CodeSelect"
fi
exit 0