Skip to content

Commit 201453d

Browse files
committed
Add CodePilot installation script
1 parent bee7905 commit 201453d

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.PHONY: install
2+
3+
install:
4+
@chmod +x ./install
5+
@bash ./install || true

install

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
echo "Installing CodePilot"
22

3+
local_bin_path=~/.local/bin
4+
35
# check if git is installed
46
if [[ -z $(which git) ]]; then
57
echo "Git is not installed"
@@ -16,42 +18,54 @@ if [[ -z $(which gh) ]]; then
1618
exit 1
1719
fi
1820

19-
curl -s https://raw.githubusercontent.com/wasertech/CodePilot/main/scripts/codepilot > codepilot
21+
# check if wget is installed
22+
if [[ -z $(which wget) ]]; then
23+
echo "wget is not installed"
24+
distro=$(lsb_release -i | cut -f 2-)
25+
echo "Please install wget on $distro"
26+
exit 1
27+
fi
28+
29+
wget -O codepilot https://raw.githubusercontent.com/wasertech/CodePilot/main/scripts/codepilot
2030
chmod +x codepilot
21-
# copy the codepilot script to /usr/local/bin
22-
echo "Copying codepilot script to /usr/local/bin"
23-
sudo cp codepilot /usr/local/bin/codepilot
31+
32+
# copy the codepilot script to $local_bin_path
33+
echo "Copying codepilot script to $local_bin_path"
34+
cp codepilot $local_bin_path/codepilot
2435
# source the codepilot script in ~/.bashrc
2536
# only if it is not already sourced
2637

2738
echo "Handling bash"
2839
if [[ -f ~/.bashrc ]]; then
29-
if [[ $(grep -c "source /usr/local/bin/codepilot" ~/.bashrc) -eq 0 ]]; then
40+
if [[ $(grep -c "source $local_bin_path/codepilot" ~/.bashrc) -eq 0 ]]; then
3041
echo "Sourcing codepilot script in ~/.bashrc"
31-
echo "source /usr/local/bin/codepilot" >> ~/.bashrc
42+
echo "source $local_bin_path/codepilot" >> ~/.bashrc
3243
else
3344
echo "CodePilot is already installed"
3445
exit 0
3546
fi
3647
else
3748
echo "Sourcing codepilot script in ~/.bashrc"
38-
echo "source /usr/local/bin/codepilot" >> ~/.bashrc
49+
echo "source $local_bin_path/codepilot" >> ~/.bashrc
3950
fi
4051

4152
echo "Handling zsh"
4253
if [[ -f ~/.zshrc ]]; then
43-
if [[ $(grep -c "source /usr/local/bin/codepilot" ~/.zshrc) -eq 0 ]]; then
54+
if [[ $(grep -c "source $local_bin_path/codepilot" ~/.zshrc) -eq 0 ]]; then
4455
echo "Sourcing codepilot script in ~/.zshrc"
45-
echo "source /usr/local/bin/codepilot" >> ~/.zshrc
56+
echo "source $local_bin_path/codepilot" >> ~/.zshrc
4657
else
4758
echo "CodePilot is already installed"
4859
exit 0
4960
fi
5061
else
5162
echo "Sourcing codepilot script in ~/.zshrc"
52-
echo "source /usr/local/bin/codepilot" >> ~/.zshrc
63+
echo "source $local_bin_path/codepilot" >> ~/.zshrc
5364
fi
5465

66+
echo "Removing useless files"
67+
rm codepilot install
68+
5569
echo "GitHub Copilot installed successfully"
5670

5771
exit 0

0 commit comments

Comments
 (0)