From 1fceddc749d546d6053f991bac7bed0c6096b256 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 21 Feb 2023 14:01:21 +0900 Subject: [PATCH] Update make symlink scripts ref: #142 --- {.config => home}/.aliases.sh | 0 {.config => home}/.bashrc | 0 {.config => home}/.default-gems | 0 {.config => home}/.stack/config.yaml | 0 {.config => home}/.zshenv | 0 scripts/make_symlink.bash | 6 +++++ scripts/make_symlinks.bash | 36 +++++++--------------------- 7 files changed, 15 insertions(+), 27 deletions(-) rename {.config => home}/.aliases.sh (100%) rename {.config => home}/.bashrc (100%) rename {.config => home}/.default-gems (100%) rename {.config => home}/.stack/config.yaml (100%) rename {.config => home}/.zshenv (100%) create mode 100755 scripts/make_symlink.bash diff --git a/.config/.aliases.sh b/home/.aliases.sh similarity index 100% rename from .config/.aliases.sh rename to home/.aliases.sh diff --git a/.config/.bashrc b/home/.bashrc similarity index 100% rename from .config/.bashrc rename to home/.bashrc diff --git a/.config/.default-gems b/home/.default-gems similarity index 100% rename from .config/.default-gems rename to home/.default-gems diff --git a/.config/.stack/config.yaml b/home/.stack/config.yaml similarity index 100% rename from .config/.stack/config.yaml rename to home/.stack/config.yaml diff --git a/.config/.zshenv b/home/.zshenv similarity index 100% rename from .config/.zshenv rename to home/.zshenv diff --git a/scripts/make_symlink.bash b/scripts/make_symlink.bash new file mode 100755 index 00000000..9b2d15a8 --- /dev/null +++ b/scripts/make_symlink.bash @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +# https://linuxjm.osdn.jp/info/GNU_coreutils/coreutils-ja_86.html +ln --symbolic --verbose --backup --relative --no-dereference --target-directory="$1" "$2" diff --git a/scripts/make_symlinks.bash b/scripts/make_symlinks.bash index 1f0d0420..051ef7f4 100755 --- a/scripts/make_symlinks.bash +++ b/scripts/make_symlinks.bash @@ -2,30 +2,12 @@ set -euxo pipefail -make_symlink() { - local create_in="$1" - local source_path="$2" - - # https://linuxjm.osdn.jp/info/GNU_coreutils/coreutils-ja_86.html - ln --symbolic --verbose --backup --relative --no-dereference --target-directory="$create_in" "$source_path" -} - -paths_to_root() { - cat <<'EOD' -.stack -.default-gems -.zshenv -.aliases.sh -.bashrc -EOD -} - -make_symlinks() { - # Can't reuse shell functions in passing to xargs... :< - paths_to_root | xargs -I{} ln --symbolic --verbose --backup --relative --no-dereference --target-directory="$HOME/.config" "./.config/{}" - - mkdir -p "$HOME/.stack" - make_symlink "$HOME/.stack" ./.config/.stack/config.yaml -} - -make_symlinks +# https://stackoverflow.com/a/24112741/1212807 +parent_path=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + pwd -P +) + +fd --hidden --type file --max-depth 1 '.' ./home | xargs -I{} "$parent_path/make_symlink.bash" "$HOME" '{}' +# TODO: Update in #142 +"$parent_path/make_symlink.bash" "$HOME/.stack" './home/.stack/config.yaml'