-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·107 lines (85 loc) · 2.52 KB
/
setup
File metadata and controls
executable file
·107 lines (85 loc) · 2.52 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
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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
echo_task() {
printf "\033[0;34m--> %s\033[0m\n" "$*"
}
error() {
printf "\033[0;31m%s\033[0m\n" "$*" >&2
exit 1
}
echo_task "Setting up dotfiles"
if [[ $(uname -s) == "Darwin" ]]; then
echo_task "Installing dependencies with Homebrew"
brew_install_if_missing() {
echo_task "Checking for $1"
if command -v "$1" >/dev/null || brew list "$1" >/dev/null; then
echo_task "$1 is already installed"
else
brew install $1
fi
}
# Install minimal dependencies for dotfiles to run
brew_install_if_missing zsh
brew_install_if_missing zsh-completions
brew_install_if_missing coreutils
brew_install_if_missing git
brew_install_if_missing vim
# Install pure prompt
brew_install_if_missing pure
elif test -f /etc/debian_version; then
echo_task "Installing dependencies with apt"
apt_install_if_missing() {
echo_task "Checking for $1"
if command -v "$1" >/dev/null; then
echo_task "$1 is already installed"
else
sudo apt install -y $1
fi
}
# Install minimal dependencies for dotfiles to run
apt_install_if_missing zsh
apt_install_if_missing git
apt_install_if_missing vim
# Install pure prompt
# https://github.com/sindresorhus/pure?tab=readme-ov-file#manually
echo_task "Checking for pure"
if test -d $HOME/.zsh/pure; then
echo_task "pure is already installed"
else
mkdir -p "$HOME/.zsh"
git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure"
fi
elif test -f /etc/fedora-release; then
echo_task "Installing dependencies with dnf"
dnf_install_if_missing() {
echo_task "Checking for $1"
if command -v "$1" >/dev/null; then
echo_task "$1 is already installed"
else
sudo dnf install $1
fi
}
# Install minimal dependencies for dotfiles to run
dnf_install_if_missing zsh
dnf_install_if_missing git
dnf_install_if_missing vim
# Install pure prompt
# https://github.com/sindresorhus/pure?tab=readme-ov-file#manually
echo_task "Checking for pure"
if test -d $HOME/.zsh/pure; then
echo_task "pure is already installed"
else
mkdir -p "$HOME/.zsh"
git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure"
fi
else
error 'Unsupported environment. Requires Homebrew/macOS or Debian/apt.';
fi
echo_task "Setting up symlinks"
for filename in $HOME/.dotfiles/dots/*; do
[ -e "$filename" ] || continue
echo_task "Installing symlink for $filename"
ln -sf "$filename" "$HOME/.$(basename $filename)"
done
echo_task "All done!"