-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
83 lines (71 loc) · 2.87 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
#!/bin/bash
# Exit immediately; unset variable = error; pipeline fails return non-zero status
set -euo pipefail
DOTFILES_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") # Get the directory of the install script
source "$DOTFILES_DIR"/config/zsh/zshenv
mkdir -p "$ZDOTDIR"
# 0. Install Homebrew if necessary
if ! command -v brew &>/dev/null; then
echo "Homebrew not found. Installing..."
# Deps: https://docs.brew.sh/Homebrew-on-Linux#requirements
export NONINTERACTIVE=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$($HOMEBREW_PREFIX/bin/brew shellenv)"
brew analytics off
fi
# 1. Brew bundle install
echo "1. Install brew bundle"
brew bundle install --file setup/Brewfile
brew cleanup
# 2. ZSH
echo "2. Set up zsh"
ln -sf "$DOTFILES_DIR"/config/zsh/zshenv "$HOME"/.zshenv
ln -sf "$DOTFILES_DIR"/config/zsh/zshrc "$ZDOTDIR"/.zshrc
ln -sf "$DOTFILES_DIR"/config/zsh/aliases "$ZDOTDIR"/aliases
ln -sf "$DOTFILES_DIR"/config/zsh/autocompletions "$ZDOTDIR"/autocompletions
ln -sf "$DOTFILES_DIR"/config/zsh/bindkeys "$ZDOTDIR"/bindkeys
ln -sf "$DOTFILES_DIR"/config/zsh/cli "$ZDOTDIR"/cli
ln -sf "$DOTFILES_DIR"/config/zsh/history "$ZDOTDIR"/history
ln -sf "$DOTFILES_DIR"/config/zsh/plugins.toml "$ZDOTDIR"/plugins.toml
ln -sf "$DOTFILES_DIR"/config/zsh/vi-mode "$ZDOTDIR"/vi-mode
ln -sf "$DOTFILES_DIR"/Taskfile.yaml "$HOME"/Taskfile.yaml
# Update or add DOTFILES_DIR export in .zprofile
touch "$ZDOTDIR"/.zprofile
if grep -q "^export DOTFILES_DIR=" "$ZDOTDIR"/.zprofile; then
sd "export DOTFILES_DIR=.*" "export DOTFILES_DIR=\"$DOTFILES_DIR\"" "$ZDOTDIR"/.zprofile
else
echo "export DOTFILES_DIR=\"$DOTFILES_DIR\"" >>"$ZDOTDIR"/.zprofile
fi
# 3. Other symlinks
echo "3. Set up other symlinks"
ln -sf "$DOTFILES_DIR"/config/bat "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/bottom "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/ghostty "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/git "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/glow "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/k9s "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/lazygit "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/nvim "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/starship "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/tealdeer "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/yazi "$XDG_CONFIG_HOME"
ln -sf "$DOTFILES_DIR"/config/zellij "$XDG_CONFIG_HOME"
# 4. Misc setups
echo "4. Misc setups"
bat cache --build # Mostly for Catppuccin theme
# 5. OS-specific setup
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "5. Set up macOS"
source setup/macos.sh
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "5. Set up Linux"
source setup/linux.sh
else
echo "(!) Unsupported OS"
exit 1
fi
if [ -n "${ZSH_VERSION+x}" ]; then
echo "✅ You are all set!"
else
echo "✅ Done, starting a new zsh session..." && zsh
fi