- Introduce `create-symlink`, `create-symlink-dir`, and `create-symlink-files` functions for managing symlinks - Add `ensure-directory` utility to ensure directory paths exist - Document new file management utilities in `library.md` - Follow existing code style and documentation format
25 lines
675 B
Bash
Executable File
25 lines
675 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
create-symlink-files() {
|
|
local source_pattern="$1"
|
|
local target_dir="$2"
|
|
|
|
# Create target directory
|
|
ensure-directory "$target_dir"
|
|
|
|
# Link each file in the source pattern
|
|
for source_file in $source_pattern; do
|
|
if [[ -f "$source_file" ]]; then
|
|
local filename=$(basename "$source_file")
|
|
local target_file="$target_dir/$filename"
|
|
|
|
# Remove existing file if it exists
|
|
if [[ -e "$target_file" || -L "$target_file" ]]; then
|
|
rm -f "$target_file"
|
|
fi
|
|
|
|
# Create the symlink
|
|
ln -sf "$source_file" "$target_file"
|
|
fi
|
|
done
|
|
} |