Feature: Built-in copy action for cross-platform clipboard support
- Dominant language
- Go
- Stars
- 83k
- Forks
- 2.9k
- Avg merge
- 17h 8m
- Merged PRs (30d)
- 10
Description
### Checklist
- [x] I have read through the manual page (`man fzf`)
- [x] I have searched through the existing issues
- [ ] For bug reports, I have checked if the bug is reproducible in the latest version of fzf
### Output of `fzf --version`
0.73.1 (ae78a5c5)
### OS
- [ ] Linux
- [x] macOS
- [ ] Windows
- [ ] Etc.
### Shell
- [ ] bash
- [x] zsh
- [ ] fish
### Problem / Steps to reproduce
**Issue:** often used snippet, but macOS only; will fail when using same setup on a non-mac
```bash
fzf --bind 'enter:execute:echo -n {1} | pbcopy'
```
**Solution:** OS-independent way to copy a string to clipboard
```bash
fzf --bind 'enter:copy-string:{1}'
```
a `paste` action seems redundant, user already has ⌃ ControlV / ⌘ CommandV
one possible use case was accessing the clipboard value, e.g. through a placeholder (not important)
```bash
# popup that disappears after 2s; modified example from CHANGELOG.md 0.63.0
echo "https://example.com" | fzf \
--bind "ctrl-y:copy-string:{}" \
--bind "ctrl-y:+change-footer:{input_paste}" \
--bind "ctrl-y:+bg-cancel+bg-transform-footer:sleep 2"
```
## tools with clipboard feature
### `broot` (rust)
- added ~2020
- current crate used:
| name | key | description |
| ----------- | ------ | ------------------------------------------ |
| copy_line | alt-c | copy selected line (in tree or preview) |
| copy_path | | copy path to system clipboard |
| input_paste | ctrl-v | paste the clipboard content into the input |
```bash
# needs to be built with feature flag (brew formula does not set it)
cargo install broot --features clipboard
# run
~/.cargo/bin/broot
# press 'alt-c' on selected item
# press 'ctrl-v' to paste
```
### `television` (rust)
handles it without a dedicated crate
-
| name | key |
| ----------------------- | ------ |
| copy_entry_to_clipboard | ctrl-y |
## additional notes
some terminals support **OSC 52** (ghostty, VSCode 1.91+, ...)
-
-
```bash
printf "\033]52;c;%s\007" "$(printf "FooBar" | base64)"
```
## related issues
- #4421
- #2323
- #2033
Contributor guide
No contributing guide indexed for this repository
Research direction
No implementation files or tests are named. Start by reviewing related issues #4421, #2323, and #2033, then compare the proposed `copy-string` binding with the existing `execute` example and the listed clipboard approaches. Done means a built-in copy action works across the supported platforms without requiring platform-specific commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100