forked from Parth/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy
executable file
·97 lines (84 loc) · 2.73 KB
/
deploy
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
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. Grab dependencies"
echo "2. Check to make sure you have zsh and tmux installed"
echo "3. We'll help you install them if you don't"
echo "4. We're going to check to see if your default shell is zsh"
echo "5. 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
git submodule update --init --recursive
check_for_software zsh
echo
check_for_software tmux
echo
check_default_shell
echo
echo -n "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
else
echo -e "\nNot backing up old dotfiles."
fi
printf "source '$HOME/dotfiles/zsh/zshrc_manager.sh'" > ~/.zshrc
printf "source-file $HOME/dotfiles/tmux/tmux.conf" > ~/.tmux.conf
echo
echo "Please log out and log back in for default shell to be initialized."