-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·130 lines (99 loc) · 2.74 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -eou pipefail
# Get absolute script path
DOTFILES_DIR="$(
cd "$(dirname "$0")" >/dev/null 2>&1
pwd -P
)"
echo "export DOTFILES_DIR=$DOTFILES_DIR" >>$DOTFILES_DIR/zsh/.zprofile
# Get OS
if [[ "$(uname)" == "Linux" ]]; then
OS="linux"
elif [[ "$(uname)" == "Darwin" ]]; then
OS="macos"
fi
# Main
main() {
echo "Current OS: $OS"
echo "Beginning installation..."
source $DOTFILES_DIR/zsh/.zshenv
mkdir -p $XDG_CONFIG_HOME $XDG_DATA_HOME $XDG_CACHE_HOME $XDG_STATE_HOME
install_packages
set_default_shell
install_antidote
create_symlinks
install_mise
mise x -- bat cache --build # Update bat themes
echo -e "\nInstallation finished, please launch Alacritty"
read -n 1 -s -r -p "Press any key to exit"
kill -9 $PPID
}
# Install Packages
install_packages() {
if [[ "$OS" == "macos" ]]; then
brew bundle install --file=Brewfile
else
xargs -a packages.txt sudo apt install -y
fi
}
# Set Zsh as default shell
set_default_shell() {
if [[ "$SHELL" != *"zsh"* ]]; then
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
fi
}
# Install Antidote
install_antidote() {
if [ ! -d $ZDOTDIR/.antidote ]; then
echo "Installing Antidote..."
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
else
echo "Antidote already installed, skipping"
fi
}
# Symlink all dotfiles
create_symlinks() {
echo "Creating symlinks..."
# zsh
rm -f ~/.zshenv && ln -s $DOTFILES_DIR/zsh/.zshenv ~/.zshenv
rm -rf $XDG_CONFIG_HOME/zsh && ln -s $DOTFILES_DIR/zsh $XDG_CONFIG_HOME/zsh
# alacritty
rm -rf $XDG_CONFIG_HOME/alacritty && ln -s $DOTFILES_DIR/alacritty $XDG_CONFIG_HOME/alacritty
# tmux
rm -rf $XDG_CONFIG_HOME/tmux && ln -s $DOTFILES_DIR/tmux $XDG_CONFIG_HOME/tmux
# mise
rm -rf $XDG_CONFIG_HOME/mise && ln -s $DOTFILES_DIR/mise $XDG_CONFIG_HOME/mise
# vim
rm -rf $XDG_CONFIG_HOME/vim && ln -s $DOTFILES_DIR/vim $XDG_CONFIG_HOME/vim
# neovim
rm -rf $XDG_CONFIG_HOME/nvim && ln -s $DOTFILES_DIR/nvim $XDG_CONFIG_HOME/nvim
# git
rm -rf $XDG_CONFIG_HOME/git && ln -s $DOTFILES_DIR/git $XDG_CONFIG_HOME/git
# bat
rm -rf $XDG_CONFIG_HOME/bat && ln -s $DOTFILES_DIR/bat $XDG_CONFIG_HOME/bat
# karabiner
if [[ "$OS" == "macos" ]]; then
rm -rf $XDG_CONFIG_HOME/karabiner && ln -s $DOTFILES_DIR/karabiner $XDG_CONFIG_HOME/karabiner
fi
# fonts
if [[ "$OS" == "macos" ]]; then
mkdir -p ~/Library/Fonts
cp $DOTFILES_DIR/fonts/* ~/Library/Fonts/
else
mkdir -p ~/.local/share/fonts
cp $DOTFILES_DIR/fonts/* ~/.local/share/fonts/
fi
}
# Install mise
install_mise() {
if ! command -v mise &>/dev/null; then
echo "Installing mise..."
curl https://mise.run | sh
else
echo "mise already installed, skipping"
fi
eval "$(~/.local/bin/mise activate bash)"
mise install -y
}
main