-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap-linux
More file actions
executable file
·46 lines (37 loc) · 1.15 KB
/
bootstrap-linux
File metadata and controls
executable file
·46 lines (37 loc) · 1.15 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
#!/usr/bin/env bash
set -euo pipefail
[[ ! -d ~/.local/bin ]] && mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
has() {
command -v "$1" 1>/dev/null 2>&1
}
# If we're on arch we can do everything with pacman.
if has pacman; then
if ! has nu; then
sudo pacman -Syu --noconfirm --disable-download-timeout nushell
fi
if ! has gh; then
sudo pacman -Syu --noconfirm --disable-download-timeout github-cli
fi
exit
fi
# If we already have nushell, we're done.
if has nu; then
exit 0
fi
# Install GitHub CLI, because we need it to download the latest nushell release.
if ! has gh; then
if has dnf; then
sudo dnf install -y gh
fi
fi
# Must be authenticated with GitHub
if ! gh auth status 2>&1 | grep -q "Logged in to"; then
printf "\033[0;31mNot logged into GitHub CLI, logging in\n"
gh auth login
fi
# Install the latest nushell release from GitHub releases to ~/.local/bin.
temp_directory=$(mktemp -d)
trap 'rm -rf -- "$temp_directory"' EXIT
gh release download -R nushell/nushell -p '*x86_64-unknown-linux-gnu.tar.gz' -O - | tar xz -C "$temp_directory"
find "$temp_directory" -type f -executable -exec cp "{}" "$HOME/.local/bin" ';'