-
Notifications
You must be signed in to change notification settings - Fork 26
/
install.sh
executable file
·154 lines (129 loc) · 3.59 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Utils
function is_installed {
# set to 1 initially
local return_=1
# set to 0 if not found
type $1 >/dev/null 2>&1 || { local return_=0; }
# return
echo "$return_"
}
function install_macos {
if [[ $OSTYPE != darwin* ]]; then
return
fi
echo "MacOS detected"
xcode-select --install
if [ "$(is_installed brew)" == "0" ]; then
echo "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if [ ! -d "/Applications/iTerm.app" ]; then
echo "Installing iTerm2"
brew tap homebrew/cask
brew install iterm2 --cask
fi
if [ "$(is_installed zsh)" == "0" ]; then
echo "Installing zsh"
brew install zsh zsh-completions
fi
if [[ ! -d ~/.oh-my-zsh ]]; then
echo "Installing oh-my-zsh"
unset ZSH
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
if [ ! -d "$ZSH/custom/plugins/zsh-autosuggestions" ]; then
echo "Installing zsh-autosuggestions"
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH/custom/plugins/zsh-autosuggestions
fi
if [ "$(is_installed ag)" == "0" ]; then
echo "Installing The silver searcher"
brew install the_silver_searcher
fi
if [ "$(is_installed fzf)" == "0" ]; then
echo "Installing fzf"
brew install fzf
/opt/homebrew/opt/fzf/install
fi
if [ "$(is_installed tmux)" == "0" ]; then
echo "Installing tmux"
brew install tmux
echo "Installing reattach-to-user-namespace"
brew install reattach-to-user-namespace
echo "Installing tmux-plugin-manager"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
if [ "$(is_installed git)" == "0" ]; then
echo "Installing Git"
brew install git
fi
if [ "$(is_installed gh)" == "0" ]; then
echo "Installing Github CLI"
brew install gh
fi
if [ "$(is_installed nvim)" == "0" ]; then
echo "Install neovim"
brew install neovim
if [ "$(is_installed pip3)" == "1" ]; then
pip3 install neovim --upgrade
fi
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
}
function backup {
echo "Backing up dotfiles"
local current_date=$(date +%s)
local backup_dir=dotfiles_$current_date
mkdir ~/$backup_dir
mv ~/.zshrc ~/$backup_dir/.zshrc
mv ~/.tmux.conf ~/$backup_dir/.tmux.conf
mv ~/.vim ~/$backup_dir/.vim
mv ~/.vimrc ~/$backup_dir/.vimrc
mv ~/.vimrc.bundles ~/$backup_dir/.vimrc.bundles
}
function link_dotfiles {
echo "Linking dotfiles"
ln -s $(pwd)/zshrc ~/.zshrc
ln -s $(pwd)/tmux.conf ~/.tmux.conf
ln -s $(pwd)/vim ~/.vim
ln -s $(pwd)/vimrc ~/.vimrc
ln -s $(pwd)/vimrc.bundles ~/.vimrc.bundles
rm -rf $HOME/.config/nvim/init.vim
rm -rf $HOME/.config/nvim
rm -rf $HOME/.vim/bundle/*
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
ln -s $(pwd)/vim $XDG_CONFIG_HOME/nvim
ln -s $(pwd)/vimrc $XDG_CONFIG_HOME/nvim/init.vim
ln -s $(pwd)/schemes/dracula.zsh-theme $HOME/.oh-my-zsh/themes/dracula.zsh-theme
if [[ ! -f ~/.zshrc.local ]]; then
echo "Creating .zshrc.local"
touch ~/.zshrc.local
fi
}
while test $# -gt 0; do
case "$1" in
--help)
echo "Help"
exit
;;
--macos)
install_macos
backup
link_dotfiles
zsh
source ~/.zshrc
exit
;;
--backup)
backup
exit
;;
--dotfiles)
link_dotfiles
exit
;;
esac
shift
done