-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinkfiles.sh
executable file
·43 lines (35 loc) · 912 Bytes
/
linkfiles.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
#! /bin/sh
# A quick deployment script for deploying dotfiles and
# bin/ from ~/dotfiles/. This could probably be better done
# using ansible.
# Steps have been taken to back up files so
# the script doesn't overwrite anything, but
# this hasn't been extensively tested.
# An existing ~/bin directory won't get
# symlinked. I would suggest backing up
# then moving ~/bin before running this.
# set -x
DOTFILES_BACKUP="$HOME/.user_dotfiles_backup.$(date +%Y.%m.%d_%H.%M.%S)"
DOTPATH=$HOME/dotfiles
cd $HOME
if [ ! -d $DOTFILES_BACKUP ]
then
mkdir $DOTFILES_BACKUP
fi
for dotfile in $(find "$DOTPATH" -maxdepth 1 -type f -name '.*' )
do
BASE=$(basename $dotfile)
if [ -e "$BASE" ]
then
mv "$BASE" $DOTFILES_BACKUP
fi
if [ -h "$BASE" ]
then
rm "$BASE"
fi
ln -s $(realpath $dotfile) $HOME
done
if [ ! -d ./bin ]
then
ln -s $HOME/$DOTPATH/bin $HOME
fi