-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-home-dir.sh
executable file
·49 lines (45 loc) · 973 Bytes
/
setup-home-dir.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
#!/bin/bash
if [[ ! -e ~/scripts/bashrc ]]
then echo "Expected scripts to be in ~/scripts"
exit 1
fi
cd "$HOME"
function lns() {
ln --backup=numbered --suffix=.old \
--verbose --symbolic --relative \
--no-target-directory "$@"
}
function mvb() {
mv --backup=numbered --suffix=.old \
--verbose \
--no-target-directory "$@"
}
function replace() {
if [[ -z "$2" ]]
then source="scripts/$1"
destination="$1"
else source="scripts/$1"
destination="$2"
fi
if [[ ! -e $source ]]
then echo "$source is missing!"
return
fi
if [[ -h "$destination" ]]
then if [[ "$destination" -ef "$source" ]]
then rm -f "$destination"
fi
else if [[ -d "$destination" ]]
then # it is a directory and not a symbolic link
mvb "$destination" "$destination".old
fi
fi
lns "$source" "$destination"
}
replace .inputrc
replace .toprc
replace .screenrc
replace .bashrc
replace .gitconfig
replace konsolerc .config/konsolerc
replace konsole .local/share/konsole