forked from Edznux/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·50 lines (40 loc) · 1.02 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.02 KB
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
echo "Installing dotfiles for user : $USER"
read -r -p "Replaced files will be backed up. Continue? [Y/n] " response
response=${response,,} # tolower
echo
if [[ ! $response =~ ^(yes|y| ) ]] & [ ! -z $response ]; then
echo "Cancelling"
exit 1
fi
#Creating back up dir
bakdir=".dotfiles_bak_$(date +%Y-%m-%d)"
mkdir ~/$bakdir
bakused=false;
#going through files, backing up if necessary
for f in $(ls -a | grep -P '^\.(?!git$)(?!\.).+$')
do
if [ -f ~/$f ]; then
cp ~/$f ~/$bakdir/$f
bakused=true;
fi
ln -fs $(pwd)/$f ~/$f
done
if [ $bakused = false ]; then
rmdir ~/$bakdir
echo "No files were overwritten"
else
echo "Backed up files available in ~/$bakdir"
fi
echo
if [ ! -f ~/.git-prompt.sh ]; then
echo "Downloading git-prompt"
curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
echo
fi
if [ ! -f ~/.lastweather ]; then
touch -t '197001010000' ~/.lastweather
fi
echo "You can now load your new config by sourcing the bashfile:"
echo
echo ". ~/.bashrc"
echo