-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup-eza
executable file
·68 lines (54 loc) · 1.65 KB
/
setup-eza
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
#!/usr/bin/env bash
set -euo pipefail
move() {
local -r src="$1"
local -r dest="$2"
local -r dest_dir="$(dirname "$dest")"
if [ ! -d "${dest_dir}" ]; then
mkdir -p "${dest_dir}"
fi
mv "${src}" "${dest}"
}
setup_for_darwin() {
echo 'brew "eza"' | brew bundle --no-lock --file=-
}
setup_for_debian() {
declare -r prefix_path="${HOME}/.local"
local temp_dir
temp_dir="$(mktemp --directory /tmp/eza--XXXXXXXXX)"
echo "$temp_dir"
cd "${temp_dir}"
local pattern
pattern="eza_$(uname -m)-unknown-linux-gnu.tar.gz"
echo "Downloading archive..."
gh release download --repo eza-community/eza --pattern "${pattern}"
gh release download --repo eza-community/eza --pattern "completions-*.tar.gz" -D ./completions
gh release download --repo eza-community/eza --pattern "man-*.tar.gz" -D ./man
echo "Extracting archive..."
tar -xzf ./eza_*.tar.gz
tar --strip-components=3 -xzf ./completions/*.tar.gz -C ./completions
tar --strip-components=3 -xzf ./man/*.tar.gz -C ./man
echo "Setting up: eza"
move ./eza "${prefix_path}/bin/eza"
move ./man/eza.1 "${prefix_path}/man/man1/eza.1"
move ./man/eza_colors-explanation.5 "${prefix_path}/man/man5/eza_colors-explanation.5"
move ./man/eza_colors.5 "${prefix_path}/man/man5/eza_colors.5"
move ./completions/eza "${prefix_path}/share/bash-completion/completions/eza"
move ./completions/_eza "${prefix_path}/share/zsh/completions/_eza"
sudo ln -nsf "${prefix_path}/bin/eza" "/usr/local/bin/eza"
echo "Cleaning up..."
rm -rf "${temp_dir}"
echo "Done!"
}
case "${OSTYPE}" in
darwin*)
setup_for_darwin
;;
linux*)
setup_for_debian
;;
*)
echo "Unknown OS!"
exit 1
;;
esac