Skip to content

laggardkernel/ranger-oscyank

Repository files navigation

ranger-oscyank

License: MIT

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 sequence.

Dependency: OSC52 support in your terminal emulator.

QuickStart

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

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

Overrides default yank key bindings in rc.conf.

# ~/.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-clipboardtmux-clipboard

# ~/.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:

# 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

About

Ranger plugin supporting copy with OSC 52

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages