Skip to content

API Reference

Adrian Thomas edited this page Oct 2, 2025 · 7 revisions

API Reference

Complete reference for all symlinkit 2.0 flags, options, and commands.


Synopsis

symlinkit [FLAGS] [SOURCE] [DESTINATION]

Operation Flags

Note: Operation flags are mandatory for CRUD operations. Inspection tools (--list, --broken, --fix-broken) do not require operation flags.

-c, --create

Create a new symlink.

Behavior: Fails if destination already exists.

symlinkit -c SOURCE DEST

Example:

symlinkit -c ~/dotfiles/.bashrc ~/.bashrc

-o, --overwrite

Overwrite existing file/directory with symlink.

Behavior: Removes existing content and replaces with symlink.

⚠️ Warning: Destructive operation. Use --dry-run first.

symlinkit -o SOURCE DEST

Example:

symlinkit --dry-run -o ~/dotfiles/.vimrc ~/.vimrc
symlinkit -o ~/dotfiles/.vimrc ~/.vimrc

-m, --merge

Recursively symlink directory contents.

Behavior: Traverses source directory and creates symlinks in destination. Prompts on conflicts.

symlinkit -m SOURCE DEST

Example:

symlinkit -m ~/dotfiles/.config ~/.config

-d, --delete

Delete a symlink.

Behavior: Removes symlink without affecting target.

symlinkit -d SYMLINK_PATH

Example:

symlinkit -d ~/.config/nvim

-r, --recursive

Enable recursive mode for create, overwrite, or delete operations.

Can be combined with:

  • -c (create recursive = merge mode)
  • -o (overwrite recursive with prompts)
  • -d (delete all symlinks in directory)

Flag chaining supported:

symlinkit -cr SOURCE DEST  # Equivalent to -m
symlinkit -or SOURCE DEST  # Recursive overwrite with prompts
symlinkit -dr DIRECTORY    # Recursively delete symlinks

Examples:

# Recursive create (same as -m)
symlinkit -cr ~/dotfiles ~/.config

# Recursive overwrite
symlinkit -or ~/dotfiles ~/.config

# Recursive delete
symlinkit -dr ~/bin

Inspection Flags

These flags do not require operation flags.

--list [DIR]

List all symlinks in a directory.

Syntax:

symlinkit --list [DIRECTORY]

Behavior: If DIRECTORY is omitted, prompts for input.

Example:

symlinkit --list ~/
symlinkit --list  # Prompts for directory

Output:

/home/user/.bashrc -> /home/user/dotfiles/.bashrc
/home/user/.zshrc -> /home/user/dotfiles/.zshrc
Found 2 symlinks in /home/user

--broken [DIR]

Find broken symlinks in a directory.

Syntax:

symlinkit --broken [DIRECTORY]

Behavior: If DIRECTORY is omitted, prompts for input.

Example:

symlinkit --broken ~/
symlinkit --broken  # Prompts for directory

Output:

/home/user/.config/old -> /nonexistent/path (broken)
Found 1 broken symlink in /home/user

--fix-broken [DIR]

Interactively fix broken symlinks.

Syntax:

symlinkit --fix-broken [DIRECTORY]

Behavior: For each broken symlink, prompts for action: delete, update, or skip.

Example:

symlinkit --fix-broken ~/
symlinkit --dry-run --fix-broken ~/  # Preview only

Interactive Prompt:

/home/user/.config/old -> /nonexistent (broken)
[d]elete / [a]ll delete / [u]pdate / [s]kip >

Utility Flags

--dry-run

Preview actions without making changes.

Syntax:

symlinkit --dry-run [OPERATION_FLAG] SOURCE DEST

Works with:

  • -c, --create
  • -o, --overwrite
  • -m, --merge
  • -d, --delete
  • --fix-broken

Example:

symlinkit --dry-run -m ~/dotfiles ~/.config
symlinkit --dry-run -o ~/source ~/dest
symlinkit --dry-run --fix-broken ~/

Output Examples:

⚠️  Would create: ~/.bashrc -> ~/dotfiles/.bashrc
✅ Would link: ~/.config/nvim
⚠️  Would delete: ~/.config/old-link

-h, --help

Show help message.

Syntax:

symlinkit --help

Output: Displays usage information and all available flags.


-v, --version

Show version and platform information.

Syntax:

symlinkit --version

Output:

symlinkit 2.0.0 (Linux)
symlinkit 2.0.0 (Darwin)
symlinkit 2.0.0 (Linux+WSL)

Arguments

SOURCE

Path to the source file or directory to be symlinked.

Optional if: Operation prompts for input when omitted.

Examples:

~/dotfiles/.bashrc
/home/user/configs/nvim
./local-file

DESTINATION

Path where the symlink should be created.

Optional if: Operation prompts for input when omitted.

Behavior with directories: If DEST is an existing directory, symlink is created inside it with source's basename.

Examples:

# DEST is file path
symlinkit -c ~/dotfiles/.bashrc ~/.bashrc

# DEST is directory (link created as ~/.config/nvim)
symlinkit -c ~/dotfiles/nvim ~/.config/

Flag Combinations

Valid Combinations

# Dry run with any operation
symlinkit --dry-run -c SOURCE DEST
symlinkit --dry-run -o SOURCE DEST
symlinkit --dry-run -m SOURCE DEST
symlinkit --dry-run -d SYMLINK
symlinkit --dry-run --fix-broken DIR

# Recursive operations
symlinkit -cr SOURCE DEST  # -c + -r
symlinkit -or SOURCE DEST  # -o + -r
symlinkit -dr DIRECTORY    # -d + -r

# Chained flags
symlinkit -c -r SOURCE DEST  # Same as -cr

Invalid Combinations

# ❌ Multiple operation flags
symlinkit -c -o SOURCE DEST  # ERROR

# ❌ No operation flag for CRUD operations
symlinkit SOURCE DEST  # ERROR

# ❌ Operation flag with inspection tools
symlinkit -c --list ~/  # ERROR

Exit Codes

Code Meaning
0 Success
1 Error (invalid arguments, operation failed, user cancelled)

Interactive Prompts

Source/Destination Prompts

When SOURCE or DEST is omitted:

Enter source directory:
Enter destination directory:

Conflict Prompts (Merge Mode)

⚠️  Conflict: ~/.config/file.txt exists.
[s]kip / [o]verwrite / [a]ll overwrite / [c]ancel >

Options:

  • s - Skip this file
  • o - Overwrite this file
  • a - Overwrite all remaining
  • c - Cancel operation

Delete Prompts (Recursive Delete)

~/.local/bin/script.sh -> ~/dotfiles/scripts/script.sh
[d]elete / [a]ll delete / [s]kip / [q]uit >

Options:

  • d - Delete this symlink
  • a - Delete all remaining
  • s - Skip this symlink
  • q - Quit

Fix-Broken Prompts

/home/user/.config/old -> /nonexistent (broken)
[d]elete / [a]ll delete / [u]pdate / [s]kip >

Options:

  • d - Delete this broken symlink
  • a - Delete all remaining broken symlinks
  • u - Update with new target path
  • s - Skip this symlink

Environment

Platform Detection

symlinkit auto-detects the operating system:

  • Linux: Uses realpath
  • macOS: Uses grealpath (via Homebrew coreutils)
  • WSL: Detected via /proc/version, uses realpath

Dependencies

Required:

  • Bash 3.2+
  • realpath (Linux/WSL) or grealpath (macOS)

No optional dependencies: All features work with required tools only.


Examples by Use Case

Dotfiles Management

# Link individual config
symlinkit -o ~/dotfiles/.zshrc ~/.zshrc

# Merge config directory
symlinkit -m ~/dotfiles/.config ~/.config

System Administration

# Find broken symlinks
symlinkit --broken /usr/local/bin

# Fix broken links
symlinkit --fix-broken /usr/local/bin

Development Workflows

# Link scripts directory
symlinkit -m ~/project/bin ~/bin

# Preview changes first
symlinkit --dry-run -m ~/project/bin ~/bin

See Also

Symlinkit Wiki Navigation

Getting Started

Features & Functionality

Development & Contributing

Clone this wiki locally