diff --git a/chezmoi.roots/_home.macos/private_dot_local/bin/executable_symlink-from-home.sh b/chezmoi.roots/_home.macos/private_dot_local/bin/executable_symlink-from-home.sh new file mode 120000 index 0000000..942451e --- /dev/null +++ b/chezmoi.roots/_home.macos/private_dot_local/bin/executable_symlink-from-home.sh @@ -0,0 +1 @@ +../../../_home/private_dot_local/bin/executable_symlink-from-home.sh \ No newline at end of file diff --git a/chezmoi.roots/_home/private_dot_local/bin/executable_symlink-from-home.sh b/chezmoi.roots/_home/private_dot_local/bin/executable_symlink-from-home.sh new file mode 100644 index 0000000..ab7d2bc --- /dev/null +++ b/chezmoi.roots/_home/private_dot_local/bin/executable_symlink-from-home.sh @@ -0,0 +1,32 @@ +#! /usr/bin/env sh +set -e + +SCRIPT_DIR=${SCRIPT_DIR:-"$( cd -- "$( dirname -- "$0" )" &> /dev/null && pwd )"} + +SRC=${1:-$(cd $SCRIPT_DIR/../.. && pwd)} +printf 'SRC=%s\n' "$SRC" +cd $SRC +( + cd "${2:-${HOME}}" + echo cleanup, phase 1... + find -P . -mindepth 1 -maxdepth 1 -type f \ + -name '.zsh_history' -or \ + -name '.gitconfig' -or \ + -name '.bash_history' -or \ + -name '.zsh_history' \ + -print -delete + + echo cleanup, phase 2... + find . -mindepth 1 -maxdepth 2 -type l -print -delete + mkdir -p .config + + echo linking... + ( + cd $SRC; ( + find . -mindepth 1 -maxdepth 1 -not -path './.config' -not -path './Dockerfile' + find .config -mindepth 1 -maxdepth 1 -not -path '*/chezmoi' -not -path '*/zellij' -not -path '*/starship*' + ) + ) | xargs -rtI '{}' ln -sr $SRC'/{}' '{}' | true +) +echo done +