-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathinstall.sh
executable file
·50 lines (44 loc) · 1.28 KB
/
install.sh
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
#!/bin/bash
main() {
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.'
exit 1
fi
if [ -f ~/.tldrrc ]; then
echo "found ~/.tldrrc, skip install process"
exit 1
fi
read -r -p "input the dir you want to store the tldr pages, e.g. /home/lord63/code/: " download_dir
tldr_pages_path="$download_dir/tldr"
if [ ! -d "$tldr_pages_path" ]; then
mkdir -p "$tldr_pages_path"
fi
echo "clone tldr pages..."
git clone https://github.com/tldr-pages/tldr.git "$tldr_pages_path"
echo "init tldr.py..."
platform="unknown"
case "$OSTYPE" in
solaris*) platform="sunos" ;;
darwin*) platform="macos" ;;
linux*) platform="linux" ;;
bsd*) platform="bsd" ;;
msys*) platform="windows" ;;
*) echo "unknown: $OSTYPE" ;;
esac
supported_platform=("linux" "sunos" "macos")
if [[ ! " ${supported_platform[*]} " == *" ${platform} "* ]]; then
echo "$platform is not in supported platform ${supported_platform[*]}"
exit 1
fi
cat <<-EOF > ~/.tldrrc
colors:
command: cyan
description: blue
usage: green
platform: $platform
repo_directory: $tldr_pages_path
EOF
echo "rebuild tldr.py..."
tldr reindex
}
main