forked from Benniphx/configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymlink_dotfiles
executable file
·75 lines (59 loc) · 1.8 KB
/
symlink_dotfiles
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
#!/bin/bash
set -e
set -u
this_path=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
### Configuration ##############################################################
dotfiles_path="$this_path/dotfiles"
# Do not symlink these paths. Paths are relative to $dotfiles_path.
do_not_symlink=(
"xfce4"
".irssi"
)
### Parse arguments ############################################################
ln_args=''
while getopts 'f' arg ; do
case "$arg" in
f)
ln_args='f'
;;
*)
exit 1
;;
esac
done
### Symlink bin ################################################################
local_bin_path="$HOME/local/bin"
mkdir -p "$local_bin_path"
if [[ ! -L "$local_bin_path" ]] ; then
mv -i "$local_bin_path" "${local_bin_path}-old"
ln -snvi"$ln_args" "$this_path/bin" "$local_bin_path"
fi
### Symlink dotfiles ###########################################################
in_array() {
local e
for e in "${@:2}" ; do
[[ "$e" == "$1" ]] && return 0
done
return 1
}
for source_file_name in $(ls -A $dotfiles_path) ; do
if (in_array "$source_file_name" "${do_not_symlink[@]}") ; then
echo "Ignoring: $source_file_name"
else
ln -snvi"$ln_args" "$dotfiles_path/$source_file_name" \
"$HOME/$source_file_name"
fi
done
### Symlink htoprc for Linux distributions #####################################
if [[ "$OSTYPE" = linux-gnu* ]] ; then
mkdir -p "$HOME/.config/htop"
ln -snvi"$ln_args" "$dotfiles_path/.htoprc" "$HOME/.config/htop/htoprc"
fi
### Symlink XFCE for Linux distributions #######################################
if [[ "$OSTYPE" = linux-gnu* ]] ; then
xfce_configs_path="$HOME/.config/xfce4"
if [[ ! -L "$xfce_configs_path" ]] ; then
mv -i "$xfce_configs_path" "${xfce_configs_path}-old"
ln -snvi"$ln_args" "$dotfiles_path/xfce4" "$xfce_configs_path"
fi
fi