Skip to content
misssgloryPublic

About

Helpers for linux clipboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

wcc - Workflow Clipboard Commander

A collection of command-line tools for clipboard operations, code analysis, and development workflow automation.

Tools Overview

Tool Purpose Description
wcn Copy to clipboard Copy file content, functions, or specific lines to clipboard
wcp Paste from clipboard Write clipboard content to files with backup and diff
wcf Function replacement Replace function implementations across Rust files
wcl List/Analyze Analyze directories and copy file contents
wcc Command wrapper Run commands and capture stdout/stderr to clipboard
wcz Zip folders Archive one or more folders with configurable ignore rules

Installation

cargo install --path .

# Or build specific binaries:
cargo build --release --bin wcn
cargo build --release --bin wcp
cargo build --release --bin wcf
cargo build --release --bin wcl
cargo build --release --bin wcc
cargo build --release --bin wcz

Configuration

All tools use a unified configuration file at ~/.config/wcc/config.toml:

[wcc]
history_dir = "/home/user/.local/state/wcc/history"
compress_above_bytes = 16384
time_format = "%H:%M:%S %d.%m.%Y"
default_cargo_mode = "debug"
# Multiline editor shortcuts (change these to avoid Zellij key conflicts)
editor_run_key = "Ctrl+Enter"
editor_run_alt_key = "F6"
editor_history_prev_key = "F7"
editor_history_next_key = "F8"
editor_undo_key = "Ctrl+Z"
editor_redo_key = "Ctrl+Shift+Z"
editor_redo_alt_key = "Alt+U" # fallback when terminal/Zellij loses Ctrl+Shift modifier
editor_word_left_key = "Ctrl+Left"
editor_word_right_key = "Ctrl+Right"
editor_delete_word_backward_key = "Ctrl+Backspace"
editor_delete_word_forward_key = "Ctrl+Delete"
editor_syntax_highlighting = true
# Opt-in: lock Zellij hotkeys while the no-argument editor is open
editor_zellij_lock = false

[wcl]
max_file_size_kb = 50
max_file_words_to_copy = 10000
skip_patterns = [".o", ".pyc", ".exe", ".bkp"]
skip_dirs = ["target", "node_modules", ".git"]
show_function_details = true
parallel_processing = true
max_threads = 8

[wcn]
show_time_in_header = true

[wcp]
auto_backup = true
backup_suffix = ".bkp"

[wcf]
auto_format = true
backup_before_replace = true

[wcz]
default_folder = "~/mg/zips/"
ignore = ["target", ".git", "*.bkp"]
ignore_regexes = []

Tool Details

wcn - Copy to Clipboard

Copy file content to clipboard, with optional filtering and function extraction.

# Copy entire file
wcn src/main.rs

# Copy first/last N lines
wcn -h 10 src/main.rs      # first 10 lines
wcn -t 20 src/main.rs      # last 20 lines
wcn -h 10 -t 10 file.rs    # show head and tail

# Extract specific function
wcn -f main src/main.rs

# Interactive file selection with fzf
wcn

# With flags
wcn -h 30 -f parse_args src/main.rs

Options:

  • -h, --head N - Copy first N lines

  • -t, --tail N - Copy last N lines

  • -f, --function NAME - Extract a specific function

Features:

  • Adds comment header with filename and timestamp

  • Respects language-specific comment syntax

  • Shows colored statistics

wcp - Paste from Clipboard

Write clipboard content to files with automatic backups and diff visualization.

# Write to specific file
wcp output.txt

# Write to path (creates directories if needed)
wcp src/new_file.rs

# Interactive with fzf
wcp

Features:

  • Creates backup (file.bkp) before overwriting

  • Shows colored diff between old and new content

  • Per-function diff statistics

  • Creates parent directories automatically

  • fzf file picker for interactive selection

wcf - Function Replacement

Replace function implementations across Rust files using clipboard content.

# Replace in entire directory
wcf src/

# Replace in specific file
wcf src/main.rs

# Interactive mode with fzf selection
wcf

Features:

  • Multi-function clipboard parsing

  • Preserves function signatures (pub, async, etc.)

  • Runs rustfmt after replacement

  • Creates backups before modifications

  • Interactive confirmation per function

  • Colored diff preview

  • Accumulates all changes to clipboard

wcl - Directory Analyzer

Analyze directories and copy file contents to clipboard.

# Analyze current directory
wcl

# Analyze specific path
wcl /path/to/project

Output:

  • Summary statistics (files, lines, words, chars, bytes)

  • Per-file breakdown with function/class detection

  • Function/class details with line numbers

  • Usage statistics (optional)

  • Full file contents for small files (configurable)

  • Configuration:

  • max_file_words_to_copy - Maximum words to include (default: 10000)

  • skip_patterns - File extensions to skip

  • skip_dirs - Directories to skip

  • parallel_processing - Enable multi-threading

wcc - Command Wrapper

Run commands and capture stdout/stderr to clipboard.

# Run command and capture output
wcc -- cargo build
wcc -- ls -la

# Build wrapper (cargo build)
wcc build
wcc build --release

# Run wrapper (cargo run)
wcc run
wcc run --release

# Configure default mode
wcc config --show
wcc config --set-cargo-mode release

Plain clipboard payload on stdout (-o / --output)

Use -o to write the exact plain-text clipboard payload to stdout instead of copying it. Normal command output and colored status messages are suppressed in this mode; the command's stdout, stderr and exit code are embedded in the payload. The flag applies to normal commands, the multiline editor, and Cargo wrappers. Failures still return a nonzero exit status. Regular mode is unchanged.

wcc -o 'echo hello' > command-result.txt
wcc -o 'echo hello | wc -c' | cat
wcc -o build --release > build-result.txt
wcc -o run > run-result.txt
wcc -o               # interactive: editor uses /dev/tty, stdout stays clean

The payload format is $ command # timestamp, [stdout], [stderr], [exit code]. No ANSI color codes, live output, or additional status text is written to stdout. Clipboard contents are not replaced when -o is used.

Interactive multiline commands

Running wcc without arguments opens a built-in Ratatui script editor. You can paste or type complete Bash scripts, including newlines, loops, redirects, &&, ||, and pipelines. The editor restores your terminal before execution; command output is shown normally and copied to the clipboard with the script, stdout, stderr, and exit code.

  • Enter inserts a newline; run/history keys are configurable under [wcc]. Defaults: Ctrl+S or F5 to run, Alt+Up / Alt+Down for history. To avoid Zellij bindings use Ctrl+Enter (if supported by your terminal) or F6 to run, F7 / F8 for history as in the example above.
  • Set any binding to "none" to disable it (e.g. editor_run_key = "none").
  • Supported keys: Ctrl+..., Alt+..., Shift+..., combinations, F1–F24, Enter, Up, Down, Left, Right, Tab, Esc, Home, End, Delete, Backspace, Insert, Space, and single character keys.
  • Ctrl+Z undo, Ctrl+Shift+Z redo; Ctrl+Left / Ctrl+Right move by word; Ctrl+Backspace / Ctrl+Delete delete a word backward/forward. All six shortcuts can be overridden or set to "none" under [wcc]. Undo stores up to 500 editing actions; paste and word deletion are single undo actions.
  • Terminal and Zellij must forward the configured key events to wcc. In terminals that do not distinguish Ctrl+Shift+Z, choose an alternative such as Alt+U.
  • Esc / Ctrl+C cancel (these safety keys are fixed).
  • Bash syntax highlighting is enabled by default, and can be disabled using editor_syntax_highlighting = false. Highlighting is lexical, not full shell parsing.
  • Arrow keys, Home, End, Backspace, Delete edit text; bracketed paste is supported.
  • Scripts run in bash -o pipefail -c (falling back to sh -c if Bash is absent). With Bash, errors in earlier pipeline stages are reflected in the final exit code.

Example of an interactive script:

set -e
cargo build --release 2>&1 | tee /tmp/wcc-build.log
rg 'warning:|error:' /tmp/wcc-build.log || true

Non-interactive use is supported as well:

printf 'echo first\nprintf "hello\n" | wc -l\n' | wcc -
wcc 'printf "hello\n" | wc -l'

Features:

  • Captures both stdout and stderr

  • Preserves colors in terminal, strips for clipboard

  • Saves command history with timestamps

  • Configurable default build mode

  • Shows diff statistics for changes

wcz - Zip Folders

Archive the contents of one or more folders. For a single folder, its contents are placed at the archive root; with multiple folders each input gets its own top-level folder.

# Uses [wcz].default_folder when configured
wcz ./project

# Multiple folders
wcz ./src ./tests

# Override destination directory
wcz -o ./zips ./project

# Explicit archive path
wcz -o ./backup.zip ./project

# Override archive filename while keeping configured/default destination
wcz -n source-snapshot ./project

# Add one-off ignores on top of config
wcz --ignore target --ignore '*.log' ./project

# Short form; comma-separated values are also accepted
wcz -i 'target,.git,*.tmp' ./project

# Add one-off regex ignores on top of config regexes
wcz --ignore-regex '^generated/' --ignore-regex '\\.cache$' ./project

Configuration lives in the same unified file as the other tools: ~/.config/wcc/config.toml. ignore accepts literal names and */? glob-style rules. ignore_regexes are matched against normalized relative paths. CLI --ignore/-i and --ignore-regex values are additive: they are appended to the configured rules for that invocation only. Both flags are repeatable and also accept comma-separated values. If default_folder is absent from an existing config and --output is not supplied, wcz writes to the current directory.

Shared Features

Colored Output

  • All tools support beautiful colored output with:

  • Heatmap colors for statistics (based on magnitude)

  • Syntax highlighting for diffs

  • Color-coded file names and function names

fzf Integration

Tools like wcn, wcp, and wcf support fzf for interactive file selection:

File preview with bat or head

  • Typing new paths supported

  • Auto-completion of existing files

Clipboard Integration

All tools automatically copy relevant content to clipboard:

  • wcn -> File content

  • wcp -> Diff summary

  • wcf -> Function replacement diff

  • wcl -> Analysis report + file contents

  • wcc -> Command output

Unified Configuration

Single config file for all tools with sensible defaults and sections for each tool.

Examples

Copy function and replace in another file

# Copy function from source
wcn -f process_data src/module.rs

# Replace in target file
wcf src/target.rs

Analyze project and copy for documentation

# Analyze and copy all small files
wcl src/

# Clipboard now contains:
# - Analysis report
# - All file contents (under 10000 words)

Backup before editing

# wcp automatically creates .bkp files
wcp config.toml

# Edit file
vim config.toml

# Restore if needed
cp config.toml.bkp config.toml

Development

Building

# Build all
cargo build --release

# Build specific tool
cargo build --release --bin wcn

Adding New Features

The tools share common modules:

  • common.rs - Shared utilities (clipboard, colors, stats)

  • lib.rs - Unified configuration handling

Dependencies

Essential:

  • anyhow - Error handling

  • arboard - Clipboard operations

  • regex - Pattern matching

  • similar - Diff generation

  • serde - Configuration serialization

Optional:

  • rayon - Parallel processing (wcl)

  • crossterm - Terminal colors

  • fzf - Interactive file selection (external)

License

MIT

Nix development shells

nix develop does not include Nix-provided cargo or rustc, so entering the default shell will not fetch the large Rust compiler. It uses whatever Rust toolchain is already on your PATH (e.g. rustup's ~/.cargo/bin). Verify with command -v cargo && rustc --version.

If Rust is not installed, run nix develop .#nix-rust to explicitly use Nix-provided Cargo and rustc. nix build still uses Nix-managed Rust and may download the compiler.

Multiline editor history (F7/F8 example)

wcc saves submitted commands, including multiline Bash scripts, as JSON lines in ~/.config/wcc/history (or $XDG_CONFIG_HOME/wcc/history). They are now recalled newest-first; the first history-previous keypress loads the latest command. The footer shows the history count and a status message. Executing an empty editor no longer closes it.

To configure Zellij-friendly bindings in the existing [wcc] section of ~/.config/wcc/config.toml:

editor_run_key = "F6"
editor_run_alt_key = "none"
editor_history_prev_key = "F7"
editor_history_next_key = "F8"
editor_syntax_highlighting = true

If history count is zero after a successful command, inspect the writable ~/.config/wcc/history file and $XDG_CONFIG_HOME.

Temporarily disable Zellij shortcuts inside wcc

In ~/.config/wcc/config.toml, add this setting to the existing [wcc] section:

editor_zellij_lock = true

By default this is false. When enabled, interactive wcc (without arguments) checks the ZELLIJ environment variable and calls zellij action switch-mode locked before opening its Ratatui editor. This is functionally equivalent to Zellij's default Ctrl+G lock binding, but avoids injecting terminal keystrokes. On Ctrl+C, Esc, the configured editor_run_key / editor_run_alt_key, or an ordinary editor error, the editor is closed and zellij action switch-mode normal is invoked before the submitted command runs. An empty submission keeps the editor open and Zellij locked. Outside Zellij, the setting has no effect.

The Zellij CLI must be available on PATH. Only successful locks are undone; failed locks show a warning and the editor continues unlocked. Zellij's switch-mode affects all clients attached to the current session, not just this pane. A force kill (SIGKILL) or power loss cannot run cleanup; if stuck in locked mode use Ctrl+G to manually unlock. This assumes the standard Zellij locked/normal modes and the default Ctrl+G unlock binding.

Redo and terminal key encoding

The editor requests Kitty keyboard enhancement (DISAMBIGUATE_ESCAPE_CODES) so compatible terminals/Zellij can distinguish Ctrl+Shift+Z from Ctrl+Z. If the terminal still emits identical events, the application cannot distinguish them. Use Alt+U to redo (configured via editor_redo_alt_key), or override editor_redo_key = "Alt+U" and editor_redo_alt_key = "none".

About

Helpers for linux clipboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages