home · contact · privacy
Update
[config] / all_new_2018 / symlink_etc.sh
1 #!/bin/sh
2 # Symbolically link files to those in argument-selected subdirectories
3 # of linkable_etc_files//, e.g. link /etc/foo/bar to
4 # linkable_etc_files/$1/etc/foo/bar and so on. Create directories as
5 # necessary.
6 # CAUTION: This removes original files at the affected paths.
7 set -e
8
9 config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/"
10
11 for target in "$@"; do
12     cd "${config_tree_prefix}${target}"
13     for path in $(find . -type f); do
14         linking=$(echo "${path}" | cut -c2-)
15         linked=$(realpath "${path}")
16         dir=$(dirname "${linking}")
17         mkdir -p "${dir}"
18         ln -fs "${linked}" "${linking}"
19     done
20 done