-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·131 lines (109 loc) · 3.57 KB
/
install.sh
File metadata and controls
executable file
·131 lines (109 loc) · 3.57 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPLETION_FILE="$SCRIPT_DIR/_claude"
echo -e "${BLUE}Claude Code ZSH Completion Installer${NC}\n"
# Check if completion file exists
if [ ! -f "$COMPLETION_FILE" ]; then
echo -e "${RED}Error: Completion file not found at $COMPLETION_FILE${NC}"
exit 1
fi
# Function to install for Oh My Zsh
install_oh_my_zsh() {
local ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
local PLUGIN_DIR="$ZSH_CUSTOM/plugins/claude-code-zsh"
echo -e "${BLUE}Installing for Oh My Zsh...${NC}"
if [ ! -d "$ZSH_CUSTOM" ]; then
echo -e "${RED}Error: Oh My Zsh custom directory not found${NC}"
echo -e "Make sure Oh My Zsh is installed first"
return 1
fi
# Create plugin directory
mkdir -p "$PLUGIN_DIR"
# Create symlinks to completion and plugin files
ln -sf "$COMPLETION_FILE" "$PLUGIN_DIR/_claude"
ln -sf "$SCRIPT_DIR/claude-code-zsh.plugin.zsh" "$PLUGIN_DIR/claude-code-zsh.plugin.zsh"
echo -e "${GREEN}✓ Installed completion file${NC}"
echo -e "\nAdd ${YELLOW}claude-code-zsh${NC} to your plugins in ~/.zshrc:"
echo -e " plugins=(... ${YELLOW}claude-code-zsh${NC})"
echo -e "\nThen run: ${YELLOW}exec zsh${NC}"
}
# Function to install manually
install_manual() {
local COMP_DIR="${ZDOTDIR:-$HOME}/.zsh/completions"
echo -e "${BLUE}Installing manually...${NC}"
# Create completions directory
mkdir -p "$COMP_DIR"
# Create symlink
ln -sf "$COMPLETION_FILE" "$COMP_DIR/_claude"
echo -e "${GREEN}✓ Installed completion file to $COMP_DIR${NC}"
echo -e "\nAdd the following to your ~/.zshrc:"
echo -e " ${YELLOW}fpath=($COMP_DIR \$fpath)${NC}"
echo -e " ${YELLOW}autoload -Uz compinit && compinit${NC}"
echo -e "\nThen run: ${YELLOW}exec zsh${NC}"
}
# Function to show Antigen instructions
show_antigen() {
echo -e "${BLUE}Antigen Installation${NC}"
echo -e "\nAdd the following to your ~/.zshrc:"
echo -e " ${YELLOW}antigen bundle $SCRIPT_DIR${NC}"
echo -e "\nThen run: ${YELLOW}exec zsh${NC}"
}
# Function to show Zinit instructions
show_zinit() {
echo -e "${BLUE}Zinit Installation${NC}"
echo -e "\nAdd the following to your ~/.zshrc:"
echo -e " ${YELLOW}zinit load $SCRIPT_DIR${NC}"
echo -e "\nOr for lazy loading:"
echo -e " ${YELLOW}zinit wait lucid for $SCRIPT_DIR${NC}"
echo -e "\nThen run: ${YELLOW}exec zsh${NC}"
}
# Function to show direct source instructions
show_direct() {
echo -e "${BLUE}Direct Sourcing${NC}"
echo -e "\nAdd the following to your ~/.zshrc:"
echo -e " ${YELLOW}fpath=($SCRIPT_DIR \$fpath)${NC}"
echo -e " ${YELLOW}autoload -Uz compinit && compinit${NC}"
echo -e "\nThen run: ${YELLOW}exec zsh${NC}"
}
# Main installation menu
echo "Choose installation method:"
echo " 1) Oh My Zsh plugin"
echo " 2) Manual (fpath)"
echo " 3) Antigen (show instructions)"
echo " 4) Zinit (show instructions)"
echo " 5) Direct source (show instructions)"
echo ""
read -p "Enter choice [1-5]: " choice
case $choice in
1)
install_oh_my_zsh
;;
2)
install_manual
;;
3)
show_antigen
;;
4)
show_zinit
;;
5)
show_direct
;;
*)
echo -e "${RED}Invalid choice${NC}"
exit 1
;;
esac
echo -e "\n${GREEN}Installation complete!${NC}"
echo -e "\n${YELLOW}Note:${NC} After installation, you may need to run:"
echo -e " ${YELLOW}rm -f ~/.zcompdump* && exec zsh${NC}"
echo -e "to clear the completion cache and reload your shell."