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