-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (74 loc) · 2.85 KB
/
install.sh
File metadata and controls
executable file
·97 lines (74 loc) · 2.85 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
#!/bin/bash
cd "${HOME}"
DOTFILE_TMPL_BASE_URL=https://raw.githubusercontent.com/yingca1/dotfiles/master
DOTFILE_BACKUP_FOLDER="${HOME}"/dotfile_backup_$(date +%Y%m%d%H%M%S)
# list all dotfiles in an array
declare -a DOTFILES=(
.gitconfig
.vimrc
.vimrc.plugins
.zshrc
.curlrc
.wgetrc
)
# backup existing dotfiles
mkdir -p "${DOTFILE_BACKUP_FOLDER}"
for dotfile in "${DOTFILES[@]}"; do
if [ -f "${HOME}"/"${dotfile}" ]; then
mv "${HOME}"/"${dotfile}" "${DOTFILE_BACKUP_FOLDER}"/
fi
done
if [ -f "${HOME}"/.oh-my-zsh ]; then
mv "${HOME}"/.oh-my-zsh "${DOTFILE_BACKUP_FOLDER}"/
fi
if [ -f "${HOME}"/.vim ]; then
mv "${HOME}"/.vim "${DOTFILE_BACKUP_FOLDER}"/
fi
if [ ! -f /bin/zsh ]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update && sudo apt-get install zsh -y
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install zsh
fi
fi
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
# install zsh-completions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
# install zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# install zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# install zsh-history-substring-search
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
# install zsh-theme
curl -fLo "${HOME}"/.oh-my-zsh/themes/yc.zsh-theme --create-dirs \
"${DOTFILE_TMPL_BASE_URL}"/yc.zsh-theme
# install plug.vim
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# for loop download remote dotfiles
for dotfile in "${DOTFILES[@]}"; do
curl -fLo "${HOME}"/"${dotfile}" --create-dirs \
"${DOTFILE_TMPL_BASE_URL}"/"${dotfile}"
done
# install tmux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update && sudo apt-get install tmux -y
curl -fLo "${HOME}"/.tmux.conf --create-dirs \
"${DOTFILE_TMPL_BASE_URL}"/.tmux.conf.linux
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install tmux
curl -fLo "${HOME}"/.tmux.conf --create-dirs \
"${DOTFILE_TMPL_BASE_URL}"/.tmux.conf.macOS
fi
touch ~/.tmux.conf.local
# install vim plugins
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update && sudo apt-get install ripgrep bat fd-find silversearcher-ag fzf -y
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install ripgrep bat fd the_silver_searcher fzf
fi
VIMRC=${HOME}/.vimrc
touch ~/.vimrc.plugins.local
vim -E -s -u "$VIMRC" +PlugInstall +qall