-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_dotfiles.sh
50 lines (45 loc) · 1.38 KB
/
install_dotfiles.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
#! /bin/bash
# Sourcing bash_profile in bashrc (create if it does not exists)
if [ ! -f $HOME/.bash_profile ]; then
echo "Bash profile does not exist, creating .bash_profile ..."
touch $HOME/.bash_profile
fi
echo "Appending Bash profile with .bashrc sourcing on startup ..."
echo ""
echo 'if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi' >> $HOME/.bash_profile
# Sourcing zprofile in zshrc (create if it does not exists)
if [ ! -f $HOME/.zprofile ]; then
echo "Zsh profile does not exist, creating .zprofile ..."
touch $HOME/.zprofile
fi
echo "Appending Zsh profile with .zshrc sourcing on startup ..."
echo ""
echo 'if [ -f $HOME/.zshrc ]; then
source $HOME/.zshrc
fi' >> $HOME/.zprofile
# Copying dotfiles
DOTFILES=(.bashrc .gitconfig .gitignore .zshrc)
for dotfile in $(echo ${DOTFILES[*]});
do
echo "Initializing $dotfile ..."
if [ -f $HOME/$(echo $dotfile) ];
then
echo ""
echo "$dotfile already exists ! Do you want to replace it ?"
select yn in "Yes" "No"; do
case $yn in
Yes )
cp ../dotfiles/$(echo $dotfile) $HOME/$(echo $dotfile)
echo ""; break;;
No )
echo ""; break;;
esac
done
else
cp $(echo $dotfile) ~/$(echo $dotfile)
fi
done
echo ""
echo "All dotfiles have been initialized. Exiting."