-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.dotfiles-install.sh
executable file
·101 lines (81 loc) · 2.82 KB
/
.dotfiles-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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/zsh
# A script to automatically download packages required by my dotfiles.
set -x
function command_exists {
command -v "$@" > /dev/null
}
# Checks if command exists. Must pass the command NAME.
function chk_command {
command_exists "$1" || {
echo "Error: '$1' is not installed. Check your PATH." >&2
exit 1
}
}
################################################################################
# Set up
################################################################################
# Check dependencies
chk_command "vim"
chk_command "awk"
chk_command "git"
chk_command "curl"
chk_command "zsh"
chk_command "ctags"
# Check dotfiles exist
if ! [[ -d "$HOME/.dotfiles" ]]; then
echo "Error: dotfiles are not installed." >&2
exit 1
fi
CURL="curl -sSL --proto-redir -all,https"
################################################################################
# Install packages
################################################################################
# oh-my-zsh
if ! [[ -d "$HOME/.oh-my-zsh" ]]; then
eval $CURL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh -s -- --unattended --keep-zshrc
else
echo "oh-my-zsh! is already installed."
fi
# zplug
export ZPLUG_HOME="$HOME/.zplug"
export ZPLUG_INIT="$ZPLUG_HOME/init.zsh"
if ! [[ -f "$ZPLUG_INIT" ]]; then
git clone https://github.com/zplug/zplug $ZPLUG_HOME
else
echo "zplug is already installed."
fi
# zplug plugins
# TODO: switch from here-string. It's a work around to zplug's incompatibility with pipes.
zsh <<< "source $HOME/.zshrc; zplug install"
# rust language
export CARGO_HOME="$HOME/.cargo"
if ! command_exists "cargo"; then
if ! [[ -d "$CARGO_HOME" ]]; then
eval $CURL https://sh.rustup.rs | sh -s -- -y
fi
export PATH="$HOME/.cargo/bin:$PATH"
else
echo "cargo is already installed."
fi
# rust packages
chk_command "cargo"
cargo install fd-find ripgrep bat git-delta exa zoxide navi
# vim plugins
vim +PlugUpdate +'w! /tmp/vim-plug.log' +qall <<< "\n" > /dev/null
cat /tmp/vim-plug.log
################################################################################
# Download Powerlevel10k fonts
################################################################################
FONTS_DIR=$HOME/.local/share/fonts
FONTS_URL=https://github.com/romkatv/powerlevel10k-media/raw/master
# Downloads and install a font with the given name from the given URL
function add_font {
eval $CURL --output "'$FONTS_DIR/$1'" $2
chmod 644 "$FONTS_DIR/$1"
}
mkdir -p $FONTS_DIR
chmod 755 $FONTS_DIR
add_font "MesloLGS NF Regular.ttf" $FONTS_URL/MesloLGS%20NF%20Regular.ttf
add_font "MesloLGS NF Bold.ttf" $FONTS_URL/MesloLGS%20NF%20Bold.ttf
add_font "MesloLGS NF Italic.ttf" $FONTS_URL/MesloLGS%20NF%20Italic.ttf
add_font "MesloLGS NF Bold Italic.ttf" $FONTS_URL/MesloLGS%20NF%20Bold%20Italic.ttf