forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
89 lines (76 loc) · 3.34 KB
/
bootstrap
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
#!/bin/bash
# Shell script to bootstrap Connexeon dotfiles config, dotbot & requirements
# attempts to install missing dependencies, so you can sit back & relax ^^
#
# Connexeon dotfiles are put together with one goal in mind:
# making shell work much efficient & easy for system engineers.
#
# There are many clever tools & tricks put together to make you fly through
# shell lightningfast and more accurate as ever before, with minimal typing
# efforts. Stop typing your ass all day & run this right now:
#
# sudo curl -sSL http://connexeon.link/dotfiles-bootstrap | bash -s
#
# Some output definitions
N=$(tput sgr0) ; BD=$(tput bold) ; GR=$(tput setaf 2; tput bold) ; YE=$(tput setaf 3) ; R=$(tput setaf 1)
OK="[$GR OK $N]\n" ; FL="[$R FAILED $N]\n"; WA="[$R WARNING $N]\n"
ZSHRC=".zshrc"
ZSH_HISTORY="~/.zsh_history"
BASH_HISTORY="~/.bash_history"
cd ~/
# Installing requirements
printf ""$BD"\nInstalling requirements"$N"\n"
YUM_PACK="zsh git python python-yaml"
APT_PACK="zsh git python python-yaml"
# Package
APT=`command -v apt-get`
YUM=`command -v yum`
GIT=`command -v git`
PYTHON=`command -v python`
if [ -n "$YUM" ]; then
printf "$YE$YUM_PACK$N\n"
sudo yum -y -q install $YUM_PACK && printf "$OK\n" || ( printf "$FL" ; exit 1 )
elif [ -n "$APT" ]; then
printf "$YE$APT_PACK$N\n"
sudo apt-get -y -q install $APT_PACK && printf "$OK\n" || ( printf "$FL" ; exit 1 )
else
printf "Unable to detect packet manager (no yum or apt-get)."
( [ ! -n $GIT ] || [ ! -f $PYTHON ] ) &&
(
printf "Missing requirement(s), please install $YE$YUM_PACK$N and run me again." >&2 ;
printf "$FL" ; exit 1
)
printf "Assuming $YE$YUM_PACK$N are installed. $OK\n"
fi
set -e
# If an .zshrc file already exists, rename it
[[ -f $ZSHRC ]] &&
( printf "$YE`pwd`$ZSHRC$N already exists, renaming yours to $YE`pwd`$ZSHRC.save$N " ;
mv $ZSHRC $ZSHRC.save && printf " $OK" || ( printf "$FL" ; exit 3 ) )
# Cloning dotfiles repo
printf ""$BD"\nCloning "$YE"dotfiles"$N$BD" into "$YE"~/.dotfiles"$N"\n"
git clone https://github.com/Connexeon/dotfiles.git ~/.dotfiles && printf "$OK\n" || ( printf "$FL" ; exit 3 )
# Installing using dotbot
printf ""$BD"\nInstalling using "$YE"dotbot"$N"\n"
cd .dotfiles && ./install && cd ~ && printf "$OK\n" || ( printf " $WA" )
# Changing shell
# If this user's login shell is not already "zsh", attempt to switch.
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if hash chsh >/dev/null 2>&1; then
printf ""$BD"Changing shell to "$YE"zsh"$N"\n"
chsh -s $(grep /zsh$ /etc/shells | tail -1)
printf "$OK\n"
# Else, suggest the user do so manually.
else
printf ""$WA"I can't change your shell automatically because this system does not have "$YE"chsh"$N."\n"
printf ""$BD"Please manually change your default shell to zsh!$N\n"
fi
fi
# Copying valueable bash history
[[ -f $BASH_HISTORY ]] &&
( printf ""$BD"Copying existing "$YE$BASH_HISTORY$N" to "$YE$ZSH_HISTORY$N"\n" ;
cat $BASH_HISTORY >> $ZSH_HISTORY && printf "$OK\n" || ( printf "$FL" ; exit 3 ) )
printf "$BD""FINISHED ^^\n\nPlease reconnect your session now to complete installation.\n" || ( printf "$FL" ; exit 1 )
printf "$BD""SSH terminal session encoding should be set to UTF-8, recommended font is DejaVu Sans Mono for Powerline.\n$N"