-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions
More file actions
executable file
·33 lines (29 loc) · 791 Bytes
/
functions
File metadata and controls
executable file
·33 lines (29 loc) · 791 Bytes
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
#!/bin/bash
set -e
function link_configs {
mkdir -pv $1/backup
for config_to_link in $1/ln_*; do
if [ -f $config_to_link ]; then
config_name=${config_to_link#*_}
[ -f ~/.$config_name ] && [ ! -L ~/.$config_name ] && mv -v ~/.$config_name $1/backup/.$config_name
ln -sfv $config_to_link ~/.$config_name
fi
done
}
function link_executables {
link_common $1 "bin"
}
function link_aliases {
link_common $1 "aliases"
}
# $1 base_dir, $2 scope
function link_common {
mkdir -pv $1/backup/$2
for linkable in $1/$2/* $1/$2/**/*; do
if [ -f $linkable ]; then
link_name=${linkable##*/}
[ -f ~/$2/$link_name ] && [ ! -L ~/$2/$link_name ] && mv -v ~/$2/$link_name $1/backup/$2/$link_name
ln -svf $linkable ~/$2/$link_name
fi
done
}