Add @override_copy_command to force copy command.

Fixes #90
This commit is contained in:
Christian Höltje 2017-06-07 00:48:32 -04:00
parent 68c5c7ca6f
commit feb9611b7d
2 changed files with 35 additions and 1 deletions

View file

@ -171,6 +171,31 @@ Configuration
- <kbd>Y</kbd> (shift-y) — "put" selection. Equivalent to copying a
selection, and pasting it to the command line.
### Default and Preferred Clipboard Programs
tmux-yank does its best to detect a reasonable choice for a clipboard
program on your OS.
If tmux-yank can't detect a known clipboard program then it uses the
`@custom_copy_command` tmux option as your clipboard program if set.
If you need to always override tmux-yank's choice for a clipboard program,
then you can set `@override_copy_command` to force tmux-yank to use whatever
you want.
Note that both programs _must_ accept `STDIN` for the text to be copied.
An example of setting `@override_copy_command`:
``` tmux
# ~/.tmux.conf
set -g @custom_copy_command 'my-clipboard-copy --some-arg'
# or
set -g @override_copy_command 'my-clipboard-copy --some-arg'
```
### Linux Clipboards
Linux has several cut-and-paste clipboards: `primary`, `secondary`, and

View file

@ -27,6 +27,9 @@
custom_copy_command_default=""
custom_copy_command_option="@custom_copy_command"
override_copy_command_default=""
override_copy_command_option="@override_copy_command"
# helper functions
get_tmux_option() {
local option="$1"
@ -75,6 +78,10 @@
custom_copy_command() {
get_tmux_option "$custom_copy_command_option" "$custom_copy_command_default"
}
override_copy_command() {
get_tmux_option "$override_copy_command_option" "$override_copy_command_default"
}
# Ensures a message is displayed for 5 seconds in tmux prompt.
# Does not override the 'display-time' tmux option.
display_message() {
@ -108,7 +115,9 @@
clipboard_copy_command() {
# installing reattach-to-user-namespace is recommended on OS X
if command_exists "pbcopy"; then
if [ -n "$(override_copy_command)" ]; then
override_copy_command
elif command_exists "pbcopy"; then
if command_exists "reattach-to-user-namespace"; then
echo "reattach-to-user-namespace pbcopy"
else