X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=all_new_2018%2Fsymlink_etc.sh;h=90cb20ab51cfdb6d07c9d8e295d3c361eea89f24;hb=a929990d8253e70799f95b1ff8a74b3a6361a9e9;hp=08f19135ddbcb3528fc68a82ff3f48d9868ca975;hpb=90a243f03a92a386a1b2b24ffc74c42f2b55a61f;p=config diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/symlink_etc.sh old mode 100644 new mode 100755 index 08f1913..90cb20a --- a/all_new_2018/symlink_etc.sh +++ b/all_new_2018/symlink_etc.sh @@ -1,14 +1,20 @@ #!/bin/sh -# Symbolically link files to those under linkable_etc_files/$1/, e.g. -# link /etc/foo/bar to linkable_etc_files/$1/etc/foo/bar. Create -# directories as necessary. +# Symbolically link files to those in argument-selected subdirectories +# of linkable_etc_files//, e.g. link /etc/foo/bar to +# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as +# necessary. # CAUTION: This removes original files at the affected paths. set -e -target="$1" config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/" -cd "${config_tree_prefix}""${target}" -for path in $(find .); do - dest=$(echo "${path}" | cut -c2-) - ln -fs "${path}" "${dest}" + +for target in "$@"; do + cd "${config_tree_prefix}${target}" + for path in $(find . -type f); do + linking=$(echo "${path}" | cut -c2-) + linked=$(realpath "${path}") + dir=$(dirname "${linking}") + mkdir -p "${dir}" + ln -fs "${linked}" "${linking}" + done done