-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·79 lines (66 loc) · 2.27 KB
/
install
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
echo "Installing CodePilot"
local_bin_path=~/.local/bin
# check if git is installed
if [[ -z $(which git) ]]; then
echo "Git is not installed"
distro=$(lsb_release -i | cut -f 2-)
echo "Please install Git on $distro"
exit 1
fi
# check if gh is installed
if [[ -z $(which gh) ]]; then
echo "GitHub CLI is not installed"
distro=$(lsb_release -i | cut -f 2-)
echo "Please install GitHub CLI on $distro"
exit 1
fi
# check if wget is installed
if [[ -z $(which wget) ]]; then
echo "wget is not installed"
distro=$(lsb_release -i | cut -f 2-)
echo "Please install wget on $distro"
exit 1
fi
wget -O codepilot.sh https://raw.githubusercontent.com/wasertech/CodePilot/main/scripts/bash/codepilot.sh 2>/dev/null
chmod +x codepilot.sh
wget -O codepilot.zsh https://raw.githubusercontent.com/wasertech/CodePilot/main/scripts/zsh/codepilot.zsh 2>/dev/null
chmod +x codepilot.zsh
mkdir -p $local_bin_path
# copy the codepilot script to $local_bin_path
echo "Copying codepilot script to $local_bin_path"
cp -f codepilot.sh codepilot.zsh $local_bin_path/
# source the codepilot script in ~/.(ba|z)shrc
# only if it is not already sourced
echo "Handling bash"
if [[ -f ~/.bashrc ]]; then
if [[ $(grep -c "source $local_bin_path/codepilot.sh" ~/.bashrc) -eq 0 ]]; then
echo "Sourcing codepilot script in ~/.bashrc"
echo "source $local_bin_path/codepilot.sh" >> ~/.bashrc
else
echo "CodePilot is already sourced in ~/.bashrc"
fi
else
echo "Sourcing codepilot script in ~/.bashrc"
echo "source $local_bin_path/codepilot.sh" >> ~/.bashrc
fi
echo "Handling zsh"
if [[ -f ~/.zshrc ]]; then
if [[ $(grep -c ". $local_bin_path/codepilot.zsh" ~/.zshrc) -eq 0 ]]; then
echo "Sourcing codepilot script in ~/.zshrc"
echo ". $local_bin_path/codepilot.zsh" >> ~/.zshrc
else
echo "CodePilot is already sourced in ~/.zshrc"
fi
else
echo "Sourcing codepilot script in ~/.zshrc"
echo ". $local_bin_path/codepilot.zsh" >> ~/.zshrc
fi
echo "Removing useless files"
if [[ ! -f README.md && ! -f Makefile ]]; then
rm -f codepilot.sh codepilot.zsh install
else
rm -f codepilot.sh codepilot.zsh
fi
echo "GitHub Copilot installed successfully"
echo "Type 'codepilot' in your favorite shell to get started"
exit 0