forked from billyevans/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·93 lines (81 loc) · 2.53 KB
/
bootstrap.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
#!/bin/bash
set -e
if [[ $OSTYPE =~ darwin* ]]; then
READLINK=$(which greadlink)
else
READLINK=$(which readlink)
fi
if [[ -z $READLINK ]]; then
echo "Failed to find readlink tool"
fi
export DIR=$(dirname $($READLINK -f $0))
echo -n $DIR > $HOME/.bootstrap_path
# bashrc
perl -pi -e "s#$DIR/.bashrc#$DIR/dotfiles/.bashrc#" ~/.bashrc
if [[ `grep $DIR/dotfiles/.bashrc ~/.bashrc` == '' ]]; then
echo "if [ -f $DIR/dotfiles/.bashrc ]; then" >> ~/.bashrc
echo " source '$DIR/dotfiles/.bashrc'" >> ~/.bashrc
echo fi >> ~/.bashrc
fi
touch ~/.bash_logout
if [[ `grep $DIR/dotfiles/.bash_logout ~/.bash_logout` == '' ]]; then
echo "if [ -f $DIR/dotfiles/.bash_logout ]; then" >> ~/.bash_logout
echo " source '$DIR/dotfiles/.bash_logout'" >> ~/.bash_logout
echo fi >> ~/.bash_logout
fi
# link all dotfiles in $HOME
for f in $(ls -1a $DIR/dotfiles)
do
if [[ $f == "." || $f == ".." || $f == ".bashrc" || $f == ".bash_logout" || $f == ".config" || $f == ".local" ]]; then
continue
fi
rm -rf $HOME/$f
ln -vs $DIR/dotfiles/$f $HOME/$f
done
# link all subfolders in $HOME/.config/*
if [[ ! -d $HOME/.config ]]; then
mkdir $HOME/.config
fi
for f in $(ls -1a $DIR/dotfiles/.config)
do
if [[ $f == "." || $f == ".." ]]; then
continue
fi
rm -rf $HOME/.config/$f
ln -vs $DIR/dotfiles/.config/$f $HOME/.config/$f
done
# link all subfolders in $HOME/.local/share/*
if [[ ! -d $HOME/.local/share ]]; then
mkdir -p $HOME/.local/share
fi
for f in $(ls -1a $DIR/dotfiles/.local/share)
do
if [[ $f == "." || $f == ".." ]]; then
continue
fi
rm -rf $HOME/.local/share/$f
ln -vs $DIR/dotfiles/.local/share/$f $HOME/.local/share/$f
done
# bootstrap.d
pushd $DIR
for script in $(ls -1 $DIR/bootstrap.d/); do
. $DIR/bootstrap.d/$script
done
popd
# fonts
if [[ -z $UPDATE_FONTS ]]; then
read -n 1 -p "Would you like to update fonts? (y/N) " UPDATE_FONTS
fi
if [[ -n $UPDATE_FONTS && $UPDATE_FONTS == 'y' ]]; then
echo "updating fonts...";
fc-cache -vf ~/.fonts/
echo "enabling bitmapped fonts in console..."
sudo rm -f /etc/fonts/conf.d/70-no-bitmaps.conf
sudo cp $DIR/files/fontconfig/50-enable-fixed.conf /etc/fonts/conf.d/
mkdir -p ~/.config/fontconfig/conf.d/
cp $DIR/files/fontconfig/10-powerline-symbols.conf ~/.config/fontconfig/conf.d/
sudo dpkg-reconfigure fontconfig
fi
echo
echo "Bootstrap is successfull!"
echo "Don't forget to launch source ~/.bashrc"