-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·107 lines (91 loc) · 2.88 KB
/
deploy.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
prompt_install() {
echo -n "$1 is not installed. Would you like to install it? (y/n) " >&2
old_stty_cfg=$(stty -g)
stty raw -echo
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
stty $old_stty_cfg && echo
if echo "$answer" | grep -iq "^y" ;then
# This could def use community support
if [ -x "$(command -v apt-get)" ]; then
sudo apt-get install $1 -y
elif [ -x "$(command -v brew)" ]; then
brew install $1
elif [ -x "$(command -v pkg)" ]; then
sudo pkg install $1
elif [ -x "$(command -v pacman)" ]; then
sudo pacman -S $1
else
echo "I'm not sure what your package manager is! Please install $1 on your own and run this deploy script again. Tests for package managers are in the deploy script you just ran starting at line 13. Feel free to make a pull request at https://github.com/parth/dotfiles :)"
fi
fi
}
check_for_software() {
echo "Checking to see if $1 is installed"
if ! [ -x "$(command -v $1)" ]; then
prompt_install $1
else
echo "$1 is installed."
fi
}
check_default_shell() {
if [ -z "${SHELL##*zsh*}" ] ;then
echo "Default shell is zsh."
else
echo -n "Default shell is not zsh. Do you want to chsh -s \$(which zsh)? (y/n)"
old_stty_cfg=$(stty -g)
stty raw -echo
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
stty $old_stty_cfg && echo
if echo "$answer" | grep -iq "^y" ;then
chsh -s $(which zsh)
else
echo "Warning: Your configuration won't work properly. If you exec zsh, it'll exec tmux which will exec your default shell which isn't zsh."
fi
fi
}
echo "We're going to do the following:"
echo "1. Check to make sure you have zsh, vim, and tmux installed"
echo "2. We'll help you install them if you don't"
echo "3. We're going to check to see if your default shell is zsh"
echo "4. We'll try to change it if it's not"
echo "Let's get started? (y/n)"
old_stty_cfg=$(stty -g)
stty raw -echo
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
stty $old_stty_cfg
if echo "$answer" | grep -iq "^y" ;then
echo
else
echo "Quitting, nothing was changed."
exit 0
fi
check_for_software zsh
echo
check_for_software vim
echo
check_for_software tmux
echo
check_default_shell
echo
echo "Would you like to backup your current dotfiles? (y/n) "
old_stty_cfg=$(stty -g)
stty raw -echo
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
stty $old_stty_cfg
if echo "$answer" | grep -iq "^y" ;then
mv ~/.zshrc ~/.zshrc.old
mv ~/.tmux.conf ~/.tmux.conf.old
mv ~/.vimrc ~/.vimrc.old
else
echo "\nNot backing up old dotfiles."
fi
echo "Pulling zsh plugins"
(cd ~/.dotfiles && git pull && git submodule update --init --recursive)
printf "source '$HOME/.dotfiles/zsh/zshrc.sh'" > ~/.zshrc
mkdir ~/.vim
mkdir ~/.vim/colors
cp ~/.dotfiles/vim/colors/* ~/.vim/colors
printf "so $HOME/.dotfiles/vim/vimrc.vim" > ~/.vim/vimrc
printf "source-file $HOME/.dotfiles/tmux/tmux.conf" > ~/.tmux.conf
echo
echo "Done!"