Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laggardkernel/ranger-oscyank

Ranger plugin supporting copy with OSC 52
https://github.com/laggardkernel/ranger-oscyank

Last synced: 29 days ago
JSON representation

Ranger plugin supporting copy with OSC 52

Awesome Lists containing this project

README

        

# ranger-oscyank

[![License: MIT][license icon]][license]

Plugin `ranger-oscyank` introduces a drop-in replacement (command `oscyank`)
for the internal command `yank`. Besides the old integration with
system clipboard manager tools (like `pbcopy`, `xsel`) in `yank`, `oscynak`
enables copying text into system clipbard with [ANSI OSC52][osc52] sequence.

Dependency: [OSC52 support][terminal-osc52-support] in your terminal emulator.

## QuickStart

Git clone the plugin into ranger's plugin folder. (`ranger >= 1.9.3`)

```bash
git clone https://github.com/laggardkernel/ranger-oscyank.git ~/.config/ranger/plugins/oscyank
```

Overrides default `yank` key bindings in `rc.conf`.

```sh
# ~/.config/ranger/rc.conf
map yp oscyank path
map yd oscyank dir
map yn oscyank name
map y. oscyank name_without_extension
```

To use `ranger-oscyank` within `tmux`, enable tmux option `set-clipboard`[tmux-clipboard]

```conf
# ~/.tmux.conf, or ~/.config/tmux/tmux.conf
set-option -g allow-passthrough on
```

## Features

### Backend Switch

`oscyank` supports two backends:

- system clipboard manager tools, like `pbcopy`, `wl-copy`, `termux-clipboard-get`,
`xclip`, `xsel`.
- ANSI OSC 52 sequence

The backend selection priority is,

1. OSC 52 when connecting thru SSH
2. Clipboard tools if any of the above is available
3. OSC 52 as fallback

You can choose the backend explicitly with special option setting:

```sh
# Force OSC 52 copying. NOTE: don't quote the value like 'osc52'.
set_oscyank backend osc52

# or
set_oscyank backend manager
```

### Quantifier

Switch path styles copied with quantifiers:

- `1` (e.g. `1yp`): replace your home path with tilde `~`
- `2`: strip the leading home path

> quantifier: If this command was mapped to the key "X" and
> the user pressed 6X, self.quantifier will be 6.

## License

The MIT License (MIT)

Copyright (c) 2024 laggardkernel

[license icon]: https://img.shields.io/badge/License-MIT-blue.svg
[license]: https://opensource.org/licenses/MIT
[osc52]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
[terminal-osc52-support]: https://github.com/ojroques/vim-oscyank#vim-oscyank
[tmux-clipboard]: https://github.com/tmux/tmux/wiki/Clipboard