-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·73 lines (59 loc) · 2.78 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/zsh
set -euo pipefail
install_tools_alpine() {
sudo apk add --update bat exa fd file fzf neovim ripgrep shfmt
sudo wget --quiet --timeout=30 --output-document=/usr/local/bin/gitprompt https://github.com/ryboe/gitprompt/releases/latest/download/gitprompt-x86_64-unknown-linux-musl
sudo chmod +x /usr/local/bin/gitprompt
# Install fzf completions manually, because apk doesn't do that for us. Note
# that this is installing the latest completions, which won't match the old
# version of fzf available on apk. Unfortunately, there's no reliable way to
# get the fzf version, because the output of `fzf --version` doesn't always
# match the git tags on the github.com/junegunn/fzf repo.
sudo wget --quiet --timeout=30 --output-document=/usr/share/fzf/completion.zsh https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh
}
install_tools_debian() {
sudo apt update
# shfmt is not available on apt yet. The shfmt package is named
# golang-mvdan-sh, but it's only in testing. See this URL for status
# updates:
# https://tracker.debian.org/pkg/golang-mvdan-sh
sudo apt install -y --no-install-recommends bat exa fd-find fzf neovim ripgrep
# bat and fd have stupid names on Debian of naming conflicts with
# preexisting packages, so give them a proper name.
mkdir -p $HOME/.local/bin
ln -s /usr/bin/batcat $HOME/.local/bin/bat
ln -s /usr/bin/fdfind $HOME/.local/bin/fd
# apt installs the fzf completions and key-bindings to a weird directory, so
# let's move them to the directory that alpine uses.
sudo mkdir -p /usr/share/fzf
sudo cp /usr/share/doc/fzf/examples/completion.zsh /usr/share/fzf/completion.zsh
sudo cp /usr/share/doc/fzf/examples/key-bindings.zsh /usr/share/fzf/key-bindings.zsh
# Install gitprompt.
wget --quiet --timeout=30 --output-document=$HOME/.local/bin/gitprompt https://github.com/ryboe/gitprompt/releases/latest/download/gitprompt-x86_64-unknown-linux-gnu
chmod +x $HOME/.local/bin/gitprompt
}
install_tools() {
if [[ -f /etc/alpine-release ]]; then
install_tools_alpine
elif [[ $(command -v lsb_release) && $(lsb_release --id --short) == Debian ]]; then
install_tools_debian
else
echo 'ERROR: unknown linux distribution'
echo 'skipping installation of command line tools'
fi
}
install_configs() {
# Delete any existing configs.
rm -rf ~/.bash_logout ~/.bashrc ~/.config/git ~/.oh-my-zsh ~/.profile ~/.zshrc
mkdir -p ~/.config/git
mkdir -p $HOME/.config/git
script_dir=${0:a:h}
mv "$script_dir/.config/git/config" $HOME/.config/git/config
mv "$script_dir/.config/git/ignore" $HOME/.config/git/ignore
mv "$script_dir/.zshrc" $HOME/.zshrc
}
main() {
install_tools
install_configs
}
main