-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·131 lines (109 loc) · 2.86 KB
/
setup.sh
File metadata and controls
executable file
·131 lines (109 loc) · 2.86 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#! /bin/bash
set -eux
install_package() {
if $mac_os; then
# Use reinstall so that this is idempotent
brew reinstall "$1"
else
sudo apt-get -o DPkg::Lock::Timeout=3 install -y "$1"
fi
}
link_file() {
ignore_files=("setup.sh" "." ".." ".git" ".config")
[[ ${ignore_files[*]} =~ $1 ]] && return
source=$link_source/$1
link=$HOME/$1
if [ -e "$link" ]; then
mkdir -p dotfiles-backup
mv "$link" dotfiles-backup
fi
ln -s "$source" "$link"
}
link_config_file() {
ignore_files=("setup.sh" "." ".." ".git" ".config")
[[ ${ignore_files[*]} =~ $1 ]] && return
source="$link_source"/"$dirname"
link=$HOME/"$dirname"
if [ -e "$link" ]; then
rm "$link"
fi
ln -s "$source" "$link"
}
[[ "$(uname -s)" == "Darwin" ]] && mac_os=true || mac_os=false
set +u
link_source="$(pwd)"
set -u
if $mac_os; then
declare -a packages=(
"bat"
"fd"
"fzf"
"git-delta"
"glow"
"nvim"
"readline"
"reattach-to-user-namespace"
"ripgrep"
"swiftlint"
"the_silver_searcher"
"tmux"
"tree"
"tree-sitter"
"tree-sitter-cli"
"wget"
"zsh-autosuggestions"
"zsh-completions"
"zsh-syntax-highlighting"
)
else
declare -a packages=(
"bat"
"curl"
"fd-find"
"fzf"
"git-delta"
"glow"
"ripgrep"
"silversearcher-ag"
"tmux"
"tree"
"tree-sitter"
"tree-sitter-cli"
"wget"
)
fi
for package in "${packages[@]}"; do
install_package "$package"
done
for filename in .*; do
link_file "$filename"
done
for dirname in .config/*; do
link_config_file $(basename $dirname)
done
mkdir -p "$HOME/bin"
for filename in bin/*; do
filename=$(basename "$filename")
[ ! -f "$HOME/bin/$filename" ] && ln -s "$link_source/bin/$filename" "$HOME/bin/$filename"
done
if [ ! -d ~/.oh-my-zsh ]; then
RUNZSH=no sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
mv -f "$HOME/.zshrc" "$HOME/.zshrc-ohmyzsh"
mv "$HOME/.zshrc.pre-oh-my-zsh" "$HOME/.zshrc"
if [ ! -d $HOME/.oh-my-zsh/custom/themes/powerlevel10k/ ]; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
fi
fi
if ! $mac_os; then
mkdir -p "$HOME/.local/share"
if [ ! -d $HOME/.local/share/zsh-autosuggestions ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions "$HOME/.local/share/zsh-autosuggestions"
fi
if [ ! -d $HOME/.local/share/zsh-completions ]; then
git clone https://github.com/zsh-users/zsh-completions.git "$HOME/.local/share/zsh-completions"
fi
if [ ! -d $HOME/.local/share/zsh-syntax-highlighting ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.local/share/zsh-syntax-highlighting"
fi
fi
[ -d ~/.local/share/tmux/plugins/tpm ] || git clone https://github.com/tmux-plugins/tpm ~/.local/share/tmux/plugins/tpm