Skip to content

API Reference

Adrian Thomas edited this page Sep 29, 2025 · 7 revisions

API Reference

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


Synopsis

symlinkit [FLAGS] [SOURCE] [DESTINATION]

Operation Flags

Required for creation and deletion operations.

-c (Create Mode)

Create a new symlink safely (fails if target exists).

Syntax:

symlinkit -c SOURCE DESTINATION

Behavior:

  • Checks if target already exists
  • Fails with helpful error if target exists
  • Creates symlink only if path is free
  • Suggests -o or -m for existing targets

Example:

symlinkit -c ~/dotfiles/.vimrc ~/.vimrc
# Result: ~/.vimrc → ~/dotfiles/.vimrc

Error case:

symlinkit -c ~/dotfiles/.vimrc ~/.vimrc
# If ~/.vimrc exists:
# ❌ Target already exists: /home/user/.vimrc
#    Use -o to overwrite or -m to merge into existing target

See: Symlink Modes#Create Mode


-o (Overwrite Mode)

Replace target with a single symlink.

Syntax:

symlinkit -o SOURCE DESTINATION

Behavior:

  • Removes existing target (file or directory)
  • Creates symlink: DESTINATION/basename(SOURCE) → SOURCE
  • Single symlink result

Example:

symlinkit -o ~/dotfiles/.vimrc ~/.vimrc
# Result: ~/.vimrc → ~/dotfiles/.vimrc

See: Symlink Modes#Overwrite Mode


-m (Merge Mode)

Recursively symlink directory contents.

Syntax:

symlinkit -m SOURCE DESTINATION

Behavior:

  • Creates destination directory if needed
  • Symlinks each file individually
  • Preserves directory structure
  • Prompts on conflicts

Example:

symlinkit -m ~/dotfiles/scripts ~/bin
# Result: ~/bin/scripts/* → ~/dotfiles/scripts/*

See: Symlink Modes#Merge Mode


-d (Delete Mode)

Remove a symlink safely.

Syntax:

symlinkit -d TARGET

Behavior:

  • Validates TARGET is a symlink
  • Shows symlink target
  • Removes symlink only (not target)
  • Errors if not a symlink

Example:

symlinkit -d ~/.vimrc
# Output: ❌ Deleted: /home/user/.vimrc → /home/user/dotfiles/.vimrc

See: Symlink Modes#Delete Mode


Preview Flags

--dry-run

Preview operations without applying changes.

Syntax:

symlinkit --dry-run [OPERATION] SOURCE DESTINATION

Behavior:

  • Shows what would happen
  • Conflicts default to "skip"
  • No filesystem changes
  • Displays summary

Example:

symlinkit --dry-run -m ~/dotfiles ~/.config
# Shows: Would link X, Would skip Y, Would overwrite Z

Compatible with: All operations


--dry-run-overwrite

Preview with conflicts defaulting to overwrite.

Syntax:

symlinkit --dry-run-overwrite -m SOURCE DESTINATION

Behavior:

  • Same as --dry-run
  • Conflicts default to "overwrite" instead of "skip"

Example:

symlinkit --dry-run-overwrite -m ~/dotfiles ~/.config

Compatible with: Merge mode


Inspection Flags

No operation flag required.

--list [DIR]

List all symlinks in directory.

Syntax:

symlinkit --list [DIRECTORY]

Parameters:

  • DIRECTORY (optional) - Directory to scan. If omitted, uses interactive selection.

Output:

📊 Found 3 symlinks in /home/user/.config
/home/user/.config/nvim → /home/user/dotfiles/nvim
/home/user/.config/tmux → /home/user/dotfiles/tmux

Example:

symlinkit --list ~/.config
symlinkit --list  # Interactive

See: Inspection Tools#List Mode


--list-verbose [DIR]

List symlinks with detailed information (ls -l style).

Syntax:

symlinkit --list-verbose [DIRECTORY]

Output:

lrwxrwxrwx 1 user user 29 Dec 10 10:30 /home/user/.config/nvim → ...

Example:

symlinkit --list-verbose ~/.config

--broken [DIR]

Find broken symlinks (pointing to non-existent targets).

Syntax:

symlinkit --broken [DIRECTORY]

Output:

📊 Found 2 broken symlinks in /home/user/.config
/home/user/.config/old → /home/user/removed/file

Example:

symlinkit --broken ~
symlinkit --broken /usr/local/bin

See: Inspection Tools#Broken Symlinks


--fix-broken [DIR]

Interactively repair broken symlinks.

Syntax:

symlinkit --fix-broken [DIRECTORY]

Interactive prompts:

  • [d]elete - Remove broken symlink
  • [u]pdate - Point to new target
  • [s]kip - Leave unchanged

Example:

symlinkit --fix-broken ~/.config

See: Inspection Tools#Fix Broken Links


--count-only [DIR]

Show only symlink count.

Syntax:

symlinkit --count-only [DIRECTORY]

Output:

🔢 5 symlinks in /home/user/.config

Example:

symlinkit --count-only ~/.config

See: Inspection Tools#Count Only


--tree [DIR]

Minimal tree view (symlinks only).

Syntax:

symlinkit --tree [DIRECTORY]

Requires: tree utility

Example:

symlinkit --tree ~/.config

See: Inspection Tools#Tree View


--tree-verbose [DIR]

Tree view with permissions and details.

Syntax:

symlinkit --tree-verbose [DIRECTORY]

Example:

symlinkit --tree-verbose ~/.config

Modifier Flags

--depth N

Limit search/tree depth.

Syntax:

symlinkit --depth N [COMMAND]

Parameters:

  • N - Integer depth level (default: 3)

Affects:

  • --tree / --tree-verbose
  • --fix-broken
  • All inspection commands

Example:

symlinkit --depth 5 --list ~/.config
symlinkit --depth 2 --tree /usr/local

See: Advanced Features#Depth Control


--sort MODE

Sort results by path or target.

Syntax:

symlinkit --sort [path|target] [COMMAND]

Parameters:

  • path - Sort by symlink path (default)
  • target - Sort by symlink target

Example:

symlinkit --sort path --list ~/.config
symlinkit --sort target --list ~/.config

See: Advanced Features#Sorting Output


--json

Output in JSON format.

Syntax:

symlinkit --json [COMMAND]

Compatible with:

  • --list
  • --broken
  • --count-only

Output format:

[
  {"path": "/home/user/.config/nvim", "target": "/home/user/dotfiles/nvim"}
]

Example:

symlinkit --json --list ~/.config
symlinkit --json --broken ~

Note: Works with or without jq installed.

See: Inspection Tools#JSON Output


Interactive Control Flags

--fzf

Force fzf usage (error if not installed).

Syntax:

symlinkit --fzf [COMMAND]

Behavior:

  • Requires fzf to be installed
  • Errors if fzf not found
  • Use in scripts requiring consistent UX

Example:

symlinkit --fzf --list

See: Interactive Selection#Force fzf Usage


--no-fzf

Disable fzf, use manual prompts only.

Syntax:

symlinkit --no-fzf [COMMAND]

Behavior:

  • Forces text input prompts
  • Works even if fzf installed
  • Use for automation or minimal environments

Example:

symlinkit --no-fzf --list

See: Interactive Selection#Force Manual Prompts


Utility Flags

-h / --help

Show help message.

Syntax:

symlinkit --help
symlinkit -h

Output: Complete flag reference and usage examples.


-v / --version

Show version and platform information.

Syntax:

symlinkit --version
symlinkit -v

Output:

symlinkit 1.7.0 (Linux+WSL)

Flag Combinations

Powerful combinations for advanced workflows.

Preview + Tree

symlinkit --dry-run -m ~/dotfiles ~/.config --tree

JSON + Sorting

symlinkit --json --sort target --list ~/.config

Depth + Count

symlinkit --depth 2 --count-only /usr

All Inspection Features

symlinkit --json --sort path --depth 5 --list ~/.config > report.json

Arguments

SOURCE

Source file or directory to symlink from.

Type: File path (absolute or relative)

Usage:

  • Required for -o and -m modes
  • Optional for -d mode (interactive if omitted)

Examples:

~/dotfiles/.vimrc
/etc/configs
./relative/path

DESTINATION

Destination directory for symlink creation.

Type: Directory path (absolute or relative)

Usage:

  • Required for -o and -m modes
  • Not used in -d mode

Examples:

~/.config
/opt/app
.

DIRECTORY

Directory to inspect (for inspection commands).

Type: Directory path (absolute or relative)

Usage:

  • Optional for all inspection commands
  • If omitted, uses interactive selection

Examples:

symlinkit --list ~/.config
symlinkit --broken /usr/local/bin
symlinkit --tree  # Interactive

Exit Codes

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

Example usage:

if symlinkit -o ~/dotfiles/.vimrc ~/.vimrc; then
  echo "Success"
else
  echo "Failed"
fi

Environment Variables

FZF_DEFAULT_OPTS

Customize fzf behavior globally.

Example:

export FZF_DEFAULT_OPTS="--height 40% --reverse --border"

Affects symlinkit's fzf usage.


Platform-Specific Behavior

Linux

Standard behavior, all features available.

macOS

  • Requires GNU utilities: grealpath, gfind
  • Automatically detected and used
  • Install via: brew install coreutils findutils

WSL (Windows Subsystem for Linux)

  • Automatic WSL detection
  • Windows path conversion via wslpath
  • Works with /mnt/c/ paths

Flag Categories

Required for Operations

  • -c (create)
  • -o (overwrite)
  • -m (merge)
  • -d (delete)

Preview/Safety

  • --dry-run
  • --dry-run-overwrite

Inspection

  • --list / --list-verbose
  • --broken
  • --fix-broken
  • --count-only
  • --tree / --tree-verbose

Modifiers

  • --depth N
  • --sort [path|target]
  • --json

Interactive Control

  • --fzf
  • --no-fzf

Utility

  • -h / --help
  • -v / --version

Common Flag Patterns

Safe Preview

symlinkit --dry-run -c SOURCE DEST
symlinkit --dry-run -o SOURCE DEST
symlinkit --dry-run -m SOURCE DEST

Visual Feedback

symlinkit -o SOURCE DEST --tree

Automated Reporting

symlinkit --json --list DIR > report.json
symlinkit --json --broken DIR > broken.json

Quick Statistics

symlinkit --count-only DIR

Deep Analysis

symlinkit --depth 10 --sort target --list DIR

Error Messages

"No operation specified"

Cause: No operation flag provided

Solution: Add -c, -o, -m, or -d

# Wrong
symlinkit source dest

# Correct (create safely)
symlinkit -c source dest

# Correct (overwrite existing)
symlinkit -o source dest

"fzf not found"

Cause: Used --fzf flag but fzf not installed

Solutions:

  1. Install fzf
  2. Remove --fzf flag
  3. Use --no-fzf

"is not a symlink"

Cause: Tried to delete non-symlink with -d

Solution: Verify target is a symlink

ls -la TARGET  # Check if it's a symlink

Quick Reference Table

Flag Args Description Requires Operation
-c src dest Create mode (safe) -
-o src dest Overwrite mode -
-m src dest Merge mode -
-d target Delete mode -
--dry-run - Preview changes No
--list [dir] List symlinks No
--broken [dir] Find broken links No
--fix-broken [dir] Repair broken No
--tree [dir] Tree view No
--count-only [dir] Count symlinks No
--depth N Set depth limit No
--sort mode Sort output No
--json - JSON output No
--fzf - Force fzf No
--no-fzf - Disable fzf No

Next Steps


Getting Help

# Built-in help
symlinkit --help

# Manual page
man symlinkit

# Online documentation
https://github.com/ctrl-alt-adrian/symlinkit/wiki

Report issues: GitHub Issues

Symlinkit Wiki Navigation

Getting Started

Features & Functionality

Development & Contributing

Clone this wiki locally