-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_links.sh
executable file
·52 lines (49 loc) · 1.41 KB
/
make_links.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
#!/usr/bin/env bash
# symlinks the dotfiles in this repository to their system location and backs
# them up if they already exist. If update-git is given as an argument, the
# system dotfilse are copied to the git repository instead. If the first
# argument is check, the integrity of the links (whether they exist and point to
# the right file) is checked.
#
# The script works with:
# 1. files that are copied directly into the home directory
# 2. directories that are copied directly into the home directory
# 3. files or directories that are copied into a subdirectory of ~ (keep in mind
# that the first part of the path still is going to be prefixed with a dot.
# config/awesome/rc.lua -> .config/awesome/rc.lua
DOTFILES=(
bashrc
inputrc
vim
vimrc
gitconfig
xinitrc
Xresources
config/sway
config/gdb
config/kitty
config/task
config/waybar
urxvt
)
GITDIR=$(readlink -e $(dirname $0))
for f in ${DOTFILES[@]}; do
if [[ $1 = "check" ]]; then
printf "["
if [[ -L ~/.$f && $(readlink ~/.$f) = ${GITDIR}/$f ]]; then
printf "✔";
else
printf "✘";
fi;
printf "] %s\n" $f;
elif [[ $1 = "update-git" ]]; then
mkdir -vp ${GITDIR}/$(dirname $f)
cp -rvT ~/.$f ${GITDIR}/$f;
else
if [[ -e ~/.$f ]] && [[ ! -L ~/.$f ]]; then
mkdir -vp ~/dotfilebackup/$(dirname $f);
mv -v ~/.$f ~/dotfilebackup/$f;
fi;
ln -svT ${GITDIR}/$f ~/.$f;
fi;
done;