-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_copilot.sh
More file actions
executable file
·49 lines (39 loc) · 1.63 KB
/
setup_copilot.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.63 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
#!/bin/bash
DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [[ `uname` == "Darwin" ]]; then
if ! [ -x "$(command -v brew)" ]; then
if ! [ -z "$YES" ] || read -q "choice?Homebrew not installed or not on path. Install? (Press Y/y): "; then
echo "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/HEAD/install.sh)"
if ! [ -x "$(command -v brew)" ]; then
echo "Homebrew not on path. Using a default."
if [[ "$(arch)" == "arm64" ]]; then
BREW="/opt/homebrew/bin/brew"
else
BREW="/usr/local/bin/brew"
fi
else
BREW="brew"
fi
else
exit 1
fi
else
BREW="brew"
fi
else # Not mac
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh jq
fi
"$BREW" install gh
"$BREW" install jq
gh auth login
gh extension install github/gh-copilot
echo "Example command explanation"
gh copilot explain "brew install bazel"
ln -s "$DIR/copilot_hook.zsh" ~/copilot_hook.zsh