Skip to content

Commit

Permalink
Update make symlink scripts
Browse files Browse the repository at this point in the history
ref: #142
  • Loading branch information
kachick committed Feb 21, 2023
1 parent ce3e164 commit 1fceddc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 27 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts/make_symlink.bash
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 9 additions & 27 deletions scripts/make_symlinks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 1fceddc

Please sign in to comment.