- 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
18 lines
431 B
Bash
Executable File
18 lines
431 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
create-symlink-dir() {
|
|
local source_dir="$1"
|
|
local target_dir="$2"
|
|
|
|
# Remove existing directory if it exists
|
|
if [[ -e "$target_dir" || -L "$target_dir" ]]; then
|
|
rm -rf "$target_dir"
|
|
fi
|
|
|
|
# Create parent directory if needed
|
|
local parent_dir=$(dirname "$target_dir")
|
|
ensure-directory "$parent_dir"
|
|
|
|
# Create symlink to directory
|
|
ln -sf "$source_dir" "$target_dir"
|
|
} |