forked from nerdpad/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·104 lines (87 loc) · 3.53 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
#!/usr/bin/env bash
command_exists() {
type "$1" > /dev/null 2>&1
}
install_dotfiles_package() {
local PACKAGE=$1
if ! command_exists "$PACKAGE"; then
read -p "Install $PACKAGE? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if ! command_exists npm; then
echo "NPM not found, so we can't install $PACKAGE"
else
echo "installing $PACKAGE"
npm install -g "$PACKAGE"
fi
fi
fi
}
# export TMUX_PLUGIN_MANAGER_PATH=~/.tmux/plugins
if command_exists apt; then
INSTALL_CMD="sudo apt install -y "
elif command_exists yum; then
INSTALL_CMD="sudo yum install -y "
elif command_exists apt-cyg; then
INSTALL_CMD="apt-cyg install "
elif command_exists pacman; then
INSTALL_CMD="sudo pacman -Sl "
else
INSTALL_CMD="I don't know how to install software packages on this system, can't install "
fi
echo "Installing dotfiles."
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
[[ ! -e "$HOME/.gitconfig" ]] && ln -s "$DOTFILES_DIR/git/gitconfig.symlink" ~/.gitconfig
[[ ! -e "$HOME/.gitignore_global" ]] && ln -s "$DOTFILES_DIR/git/gitignore_global.symlink" ~/.gitignore_global
mkdir -p ~/.oldtmux~
[[ -h "$HOME/.tmux.conf" ]] && rm ~/.tmux.conf
[[ -e "$HOME/.tmux.conf" ]] && mv ~/.tmux.conf "$HOME/.oldtmux~/.tmux.conf.bak.$(date +%Y%m%d%H%M%S)~"
[[ -h "$HOME/.tmux/tmux.conf" ]] && rm ~/.tmux/tmux.conf
[[ -e "$HOME/.tmux/tmux.conf" ]] && mv ~/.tmux/tmux.conf "$HOME/.tmux/.tmux.conf.bak.$(date +%Y%m%d%H%M%S)~"
ln -s "$DOTFILES_DIR/tmux/tmux.conf.symlink" ~/.tmux.conf
if [[ ! -d "$HOME/.tmux/plugins/tpm" ]]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
~/.tmux/plugins/tpm/bin/install_plugins
else
~/.tmux/plugins/tpm/bin/update_plugins all
fi
[[ ! -e "$HOME/.eslintrc" ]] && ln -s "$DOTFILES_DIR/eslintrc.symlink" ~/.eslintrc
[[ ! -e "$HOME/.jshintrc" ]] && ln -s "$DOTFILES_DIR/jshintrc.symlink" ~/.jshintrc
[[ ! -e "$HOME/.jscsrc" ]] && ln -s "$DOTFILES_DIR/jscsrc.symlink_excluded" ~/.jscsrc
[[ ! -e "$HOME/.jsbeautifyrc" ]] && ln -s "$DOTFILES_DIR/jsbeautifyrc.symlink" ~/.jsbeautifyrc
[[ ! -e "$HOME/.editorconfig" ]] && ln -s "$DOTFILES_DIR/editorconfig.symlink" ~/.editorconfig
[[ ! -e "$HOME/.dircolors" ]] && ln -s "$DOTFILES_DIR/dircolors.symlink" ~/.dircolors
[[ ! -e "$HOME/.sqliterc" ]] && ln -s "$DOTFILES_DIR/sqliterc.symlink" ~/.sqliterc
for I in "$DOTFILES_DIR"/resources/*; do tic "$I"; done
if ! command_exists npm; then
read -p "Install NPM? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "installing npm..."
$INSTALL_CMD npm
fi
fi
install_dotfiles_package diff-so-fancy
install_dotfiles_package js-beautify
install_dotfiles_package namecheap-cli
# install_dotfiles_package jscs
# install_dotfiles_package jshint
# install_dotfiles_package eslint
read -p "Customize Vim? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if ! command_exists vim; then
$INSTALL_CMD vim
fi
[[ -e "$HOME/.vimrc" ]] && mv ~/.vimrc "$HOME/.vimrc.bak.$(date +%Y%m%d%H%M%S)~"
ln -s "$DOTFILES_DIR/vimrc.symlink" ~/.vimrc
[[ ! -d "$HOME/.vim/bundle/Vundle.vim" ]] && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
if [[ ! -d "$HOME/.vim/bundle/Vundle.vim" ]]; then
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
else
vim +PluginUpdate +qall
fi
fi
echo "Done. Reloading your terminal..."
exec bash