blob: 210c967ea1b3e6958caf7647c7aeec4c9c046c73 (
plain)
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
|
#!/usr/bin/env bash
get_links()
{
find $HOME -not -path "$HOME/dotfiles/*" -type l | while read line; do
if [[ "$(realpath -q $line)" == "${HOME}/dotfiles/"* ]]; then
echo $line
fi
done
}
clean()
{
get_links | while read link; do
rm -v ${link}
done
}
down()
{
source $HOME/dotfiles/.dotmap
for link in "${!dotmap[@]}"; do
echo "Removing ${link}."
rm -rf $link
done
}
up()
{
source $HOME/dotfiles/.dotmap
for link in "${!dotmap[@]}"; do
target=${dotmap[$link]}
mkdir -p $(dirname ${link})
echo "Linking $target."
rm -rf $link && ln -s $target $link
done
}
save()
{
echo "declare -A dotmap" > .dotmap
get_links | while read link; do
echo "dotmap[$link]=$(realpath -q $link)" >> .dotmap
done
}
$1
|