Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·72 lines (61 loc) · 2.61 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·72 lines (61 loc) · 2.61 KB
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
#!/bin/bash
#
# macOS developer environment setup
# Usage: ./install.sh
#
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ----------------------------------------------------------------------
# 1. Homebrew
# ----------------------------------------------------------------------
echo "==> Installing Homebrew"
if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Load brew into the current shell (Apple Silicon -> /opt/homebrew, Intel -> /usr/local)
if [[ -x /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
# ----------------------------------------------------------------------
# 2. Packages
# ----------------------------------------------------------------------
echo "==> Installing packages from Brewfile"
brew bundle --file="${DOTFILES_DIR}/Brewfile"
# ----------------------------------------------------------------------
# 3. oh-my-zsh + theme + plugins
# ----------------------------------------------------------------------
echo "==> Installing oh-my-zsh"
if [[ ! -d "$HOME/.oh-my-zsh" ]]; then
RUNZSH=no KEEP_ZSHRC=yes sh -c \
"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
echo "==> Installing powerlevel10k theme"
if [[ ! -d "$ZSH_CUSTOM/themes/powerlevel10k" ]]; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
"$ZSH_CUSTOM/themes/powerlevel10k"
fi
echo "==> Installing zsh plugins"
if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]]; then
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions \
"$ZSH_CUSTOM/plugins/zsh-autosuggestions"
fi
if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]]; then
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting \
"$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
fi
# ----------------------------------------------------------------------
# 4. Symlink dotfiles (existing files are backed up)
# ----------------------------------------------------------------------
echo "==> Linking dotfiles"
backup() { [[ -e "$1" && ! -L "$1" ]] && mv "$1" "$1.backup.$(date +%s)" || true; }
backup "$HOME/.zshrc"
backup "$HOME/.vimrc"
ln -sf "${DOTFILES_DIR}/zsh-file/zshrc.txt" "$HOME/.zshrc"
ln -sf "${DOTFILES_DIR}/vim-file/vimrc.txt" "$HOME/.vimrc"
echo ""
echo "==> Done!"
echo " - Restart your terminal (or run: exec zsh)"
echo " - Configure the prompt with: p10k configure"