forked from Parth/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·66 lines (60 loc) · 1.51 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
prompt_install() {
echo -n "Heads up! $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
case "$(uname -s)" in
Darwin)
brew install $1
;;
Linux)
sudo apt install $1
;;
FreeBSD)
sudo pkg install $1
;;
*)
echo "Operating system not recognized, please install $1 manually"
;;
esac
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 "Default shell is not zsh. Attempting chsh"
chsh -s $(which zsh)
echo "Full logout may be necessary"
fi
}
check_for_software zsh
check_for_software vim
check_for_software tmux
check_default_shell
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
mv ~/.vimrc ~/.vimrc.old
else
echo -e "\nNot backing up old dotfiles."
fi
printf "source '$HOME/dotfiles/zsh/zshrc_manager.sh'" > ~/.zshrc
printf "so $HOME/dotfiles/vim/vimrc.vim" > ~/.vimrc
printf "source-file $HOME/dotfiles/tmux/tmux.conf" > ~/.tmux.conf
exec zsh